Is there a JavaScript event fired when adding a widget?

Posted by Community Admin on 04-Aug-2018 15:48

Is there a JavaScript event fired when adding a widget?

All Replies

Posted by Community Admin on 24-Sep-2014 00:00

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.

Posted by Community Admin on 29-Sep-2014 00:00

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



Regards,
Nikola Zagorchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed