Select to view content in your preferred language

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

17805
3
05-20-2015 03:22 AM
SadanandacharB1
Occasional Contributor

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

0 Kudos
3 Replies
ChrisSmith7
Honored 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
Frequent 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
Honored 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