Select to view content in your preferred language

how to call module function on button click event in html page

17397
3
05-20-2015 03:22 AM
SadanandacharB1
New Contributor III

how to call module function on button click event in html page

0 Kudos
3 Replies
ChrisSmith7
Frequent Contributor

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>
0 Kudos
OwenEarley
Regular Contributor

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;
0 Kudos
ChrisSmith7
Frequent Contributor

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...

0 Kudos