Prasoon Joshi
Prasoon Joshi

Reputation: 799

How to run onLoad event for a Dojo Dialog?

I have a Dojo dialog with content coming in from an ajax call. In the dialog I need an onLoad event (with parameters that are available only after the ajax call - so I cannot have the function called before myDialog.show() ) The onLoad event that I have in the body tag of my jsp which is the response from the ajax call is not being called - <body onload="new_record(${record_size}, '${id}')"> Any help/hint would be very nice. Thanks.

Upvotes: 4

Views: 6092

Answers (1)

Vijay Agrawal
Vijay Agrawal

Reputation: 3821

Dijit dialog supports an onShow method - you can do your AJAX pull of the dialog content in the onShow method and then populate the dialog contents.

Note that dialog content is usually embedded inside a dijit contentpane or a div

dojo.connect(myDialog, "onShow", null, function(e) {
   //do AJAX call
   // in the callback function, populate the dialog contents
});

Also see http://www.ibm.com/developerworks/web/tutorials/wa-dojotoolkit/section7.html for an example

hth

Upvotes: 2

Related Questions