More in this section
Forums / Developing with Sitefinity / Is there a JavaScript event fired when adding a widget?

Is there a JavaScript event fired when adding a widget?

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Brian
    Brian avatar
    8 posts
    02 Aug 2014
    24 Sep 2014
    Link to this post
    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.
  2. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    19 Apr 2017
    29 Sep 2014
    Link to this post
    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;
            //If dock is dropped at allowed location - call execCommand
            if (createNew && this._canCreate) this.execCommand("new", dock); // execute the command - initializes the control
            //Fix the zone css
            if (!this._canCreate)
       // execute your scripts

    Nikola Zagorchev
    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
2 posts, 0 answered