Is there a JavaScript event fired when adding a widget?
I have a few custom widgets that require javascript functions to render correctly. I'm currently using jQuery and $(document).ready to initialise the widgets. However, when I add the widgets in Edit mode there is no page reload. Is there any JavaScript event raised in the Edit page when adding a widget to the page? If so, I can then subscribe to the event to reinitialise my widgets.
Hi Brian,
There is an event that is fired when a control is dragged on the page, however, you will not be able to modify and call functions from the control, since its script view - client side initialization will not be performed, instead, the server side InitializeControls will be called. If you want to modify the control after the server side events are executed, you should hook for the ZoneEditor scripts _onToolboxDockDragEnd function event. Unfortunately, you should override the function using its prototype:
Telerik.Sitefinity.Web.UI.ZoneEditor.prototype._onToolboxDockDragEnd = function (dock, args) var createNew = false; //Test if new zone belongs to the this._wrapperDockingZones var curZone = dock.get_dockZone(); var zones = this._wrapperDockingZones; for (var i = 0; i < zones.length; i++) var zone = $find(zones[i]); if (zone == curZone) createNew = true; break; //If dock is dropped at allowed location - call execCommand if (createNew && this._canCreate) this.execCommand("new", dock); // execute the command - initializes the control this._destroyDock(dock); //Fix the zone css this._configureZoneCss(dock.get_dockZone()); if (!this._canCreate) alert(this._notAuthorizedMessage); // execute your scripts