Jquery solution to map print template?
Hi all
Fairly new to pogramming & jquery, in at the deep end and learning fast :)
I am developing a mapping application (C# ASP.net) and I have a map with several Ajax controls and tools on my default aspx page which all work fine.
I am trying to capture the map div from a button trigger (Printbtn) and send it to another HTML page (print.htm) which will be my print template.
I am using...
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
So far I have...
- <script type="text/javascript">
$(document).ready(function() {
$("button[id$=Printbtn]").click(function() {
var mapObj = $("MapCell_Map1");
var mapHtmlStr = mapObj.html();
mapHtmlStr = mapHtmlStr.replace(/CURSOR: crosshair; /g, "");
mapHtmlStr = mapHtmlStr.replace("Maps['Map1'].pendingTiles.remove", "return;");
mapHtmlStr = mapHtmlStr.replace("Maps['Map1'].pendingTiles.remove", "return;");
mapHtmlStr = mapHtmlStr.replace("Maps['Map1'].pendingTiles.remove", "return;");
mapHtmlStr = mapHtmlStr.replace("Maps['Map1'].pendingTiles.remove", "return;");
mapHtmlStr = mapHtmlStr.replace("Maps['Map1'].keyFocus=true;", "");
$.ajax({url:"print.htm", context: document.body,
success: function(response){
var printDoc = $(response);
printDoc.find("#mapPanel").html(mapHtmlStr);
var pwin = window.open("#");
var pdoc = window.document.open();
pdoc.write(printDoc.html());
pdoc.close();
return false;
});
});
</script>
The project compiles but when I trigger the button (Printbtn) a full postback occurs and no new window is fired.
Any help would be greatly appreciated!
Thanks,
Tom