i need to hook an onclick event to an element that doesnt exist until a dijit is created
editorWidget = new Editor(params,'editorDiv'); editorWidget.startup(); //override attribute button to show attribute pane function openAttribute(){ registry.byId("EditContainer").selectChild(registry.byId("editAttributePane")); }; //element doesnt exist until editorWidget is done being created, so sometimes this works, sometimes it doesnt registry.byId('btnAttributes').attr('onClick', openAttribute);
but the registry.byId('btnAttributes') is null until the editor dijit is done being created. I would prefer not to set timeouts (i even tried 3 seconds, seems 50/50 that it would work)
Is there a way to figure out that the editor dijit is done starting up?
//override attribute button to show attribute pane function openAttribute(){ registry.byId("EditContainer").selectChild(registry.byId("editAttributePane")); }; //element doesnt exist until editorWidget is done being created, so sometimes this works, sometimes it doesnt function waitForWidget() { var widget = registry.byId('btnAttributes'); if (!widget) { setTimeout(waitForWidget, 500); // setTimeout(func, timeMS, params...) } else { // Set location on form here if it isn't in getLocation() widget.attr('onClick', openAttribute); } } waitForWidget();