javascript - Dijit Dialog Button Event Not Executing -


i have dijit dialog (jsfiddle) created programmatically. when dialog show called pass id's buttons @ runtime. trying create click event functions execute id's passed @ runtime.

however events not executing. know how attach function dialog buttons.

html

<button id="show">show dialog</button>  

js

require([     "dijit/form/checkbox",     "dijit/dijit",     "dijit/form/textarea",     "dijit/form/filteringselect",     "dijit/form/textbox",     "dijit/form/validationtextbox",     "dijit/form/datetextbox",     "dijit/form/timetextbox",     "dijit/form/button",     "dijit/form/radiobutton",     "dijit/form/form",     "dijit/_dialogmixin"]); require([     "dojo/parser",     "dojo/_base/declare",     "dojo/domready!",     "dojo/ready"],  function (parser, declare, ready, dialog) {     parser.parse();      dojo.ready(function () {         function showdialog(yesbtnid, nobtnid) {             var dialog = new dijit.dialog({                 title: 'confirmation',                 content: '<table style= "width: 300px;">' +                     '<tr>' +                     '<th style="text-align:center; padding: 5px" colspan="2"><label>are sure ?</label></th>' +                     '</tr>' +                     '<tr>' +                     '<td style="text-align:center; padding: 5px"><button id=' + yesbtnid + '>yes</button></td>' +                     '<td style="text-align:center;padding: 5px"><button id= ' + nobtnid + '>no</button></td>' +                     '</tr>' +                     '</table>'             });              dialog.show();         }          var myshowbtn = {             id: "show",             onclick: function (evt) {                  showdialog('yesdelete', 'nodelete');             }         };         dojo.query("#show").connect("onclick", myshowbtn.onclick);          var myyesdelete = {             id: "yesdelete",             onclick: function (evt) {                  alert('hello working....');              }         };          dojo.query("#yesdelete").connect("onclick", myyesdelete.onclick);      }); }); 

you're trying add event handler element not exist yet when call it, event handler not bound because @ moment there's nothing bind to.

however, if move line:

dojo.query("#yesdelete").connect("onclick", myyesdelete.onclick); 

up showdialog() function (put behind dialog.show()), work can see in updated jsfiddle.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -