Populating a Dialog

723
3
03-14-2014 10:50 AM
RonVincent
Occasional Contributor
I have the HTML content for a Dijit dialog in another file which I can load into a Dijit Dialog like this:

        var dialog = dijit.byId('frmTargetDialog');
          dialog.placeAt(dojo.body());
          dialog.startup();

          dialog.show();
          
          var latWidget = dojo.byId("targetLatDD"); // ERRORS HERE
          latWidget.set("value", 25);


Here is the Div that contains the Dialog:
<div data-dojo-type="dijit/Dialog" id="frmTargetDialog" title="Target Dialog" data-dojo-props="href: 'Form.html'"></div>


However, if I try to access the Dijits in the dialog I get a null exception. Anyone know how to access the dijits so that I can populate them? I've tried accessing the textbox before and after showing the dialog and nothing seems to work.


Thanks,

Ron
0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor
Try using dijit/registry to get a reference to those items in the Dialog widget. Take a look at the documentation on using registry.
0 Kudos
RonVincent
Occasional Contributor
Try using dijit/registry to get a reference to those items in the Dialog widget. Take a look at the documentation on using registry.


That was one of the first things I tried. Didn't work.

 var latWidget = registry.byId("targetLatDD");
0 Kudos
RonVincent
Occasional Contributor
Solution found. It turns out that you have connect up the onLoad event and then you can find the elements like this:

 var handle = dojo.connect(dialog, "onLoad", function(){
            dojo.disconnect(handle);
            var latWidget = registry.byId("targetLatDD");
            latWidget.set("value", "123");
    });

0 Kudos