Search code examples
javascriptdom-eventsyui

Execute JS on dialog onload


I would like to execute some JS function each time my YUI dialog gets loaded. I can't do that from body onload because that body tag belongs to parent page. I tried doing that by adding the function on onContentReady event. But that works only when the dialog gets loaded for the first time. Then if I close the dialog and reopen it, it doesn't work; probably because the content is already ready when the dialog was opened for the first time and hence the function is not called this time.

Any idea what can be done to solve this?


Solution

  • I decided to use dialog.changeContentEvent.subscribe to register the JS code I wanted to execute on dialog onload. This isn't exactly equivalent to onload but still suits my requirement.