how to call module function on button click event in html page
Here's how I do it (for a link, but same concept for button):
Main map module (which calls another module - mapPrint)
window.mapPrintExec = function () { var objMapPrint = new mapPrint({ "contentHTML": document.documentElement.innerHTML, "pageHeight": $('.tundra').height(), "pageWidth": $('.tundra').width(), "trgNodeRef": dom.byId("mapPrintLink"), "mapDescription": strMapDesc, "mapSource": strMapSource }); objMapPrint.print(); }
HTML
<a href="#" class="emptyLink" id="mapPrintLink" onclick="mapPrintExec();"><img src="../ContentHandlers/Images/Images.ashx?printer.png" /> Print</a>
As an alternative to using the onclick event in the HTML node you can hook up the event using Javascript:
// Use a function pointer:
document.getElementById("myButtonId").onclick = doSomething;
Just in case he's looking for a dojo-specific example!
registry.byId("myButtonId").connect("onClick", function myFunc(){ doSomething; });
I find myself mixing dojo, jQuery, and pure JS sometimes...