+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Need to handle a designer event...

Need to handle a designer event...

3 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    06 Feb 2011
    Link to this post
    I have a script called on document.ready for a control....so that's all awesome, but when I move the control to another dock zone the function needs to be triggered again...

    Is there some way I can get that done aside from a timer?
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    06 Feb 2011
    Link to this post
    Also I'd like to know how to handle the callback after "Save" has been completed...I need to run a script
  3. Lyubomir Dokov
    Lyubomir Dokov avatar
    43 posts
    Registered:
    01 Nov 2016
    07 Feb 2011
    Link to this post
    Hello Steve,

    As for the first question - how to handle moving a control from one placeholder to another:

    First of all, you need to obtain the instance of the main JavaScript object that handles the page editor. This must be done in the onload event:

    var ze = $find("ZoneEditor");

    After that, if you want to hook before the event(before the change is persisted to server), you can subscribe for the command event of this object, like this:

    ze.add_command(Function.createDelegate(
        this, function (sender, args) {
            if (args.CommandName == "indexchanged") {
                //Do something here
            }
        }
    ));

    If you want to do something on success(after the change is persisted successfully), you can do something like that:

    ze._commandSuccessDelegate = Function.createDelegate(
        this, function (caller, data, request, context) {
            //Note, that here you are redefining the success delegate, so
            //you need to invoke the default method at some place in order everything to be working
            ze._commandSuccess(caller, data, request, context);
        }
    );

    The second question - how to do something after the page is saved:

    You can redefine the delegates for success, just like in the previous example. This time the object you need is the toolbar object. It handles Save Draft and Publish commands. It is defined in a file named EditorToolBar.js, if you need to look at it. You will have to redefine the following delegates:

    editorToolBar._saveDraftSuccessDelegate - this is invoked after successfully saving the page as draft.
    editorToolBar._publishDraftSuccessDelegate - this is invoked after successfully publishing the page.

    Here you also need to invoke the default functions in order everything to be working fine. Note, that editorToolBar is a global object and should be available in the onload event.

    I hope this answers your questions.


    All the best,
    Lyubomir Dokov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
3 posts, 0 answered