Need to handle a designer event...

Posted by Community Admin on 05-Aug-2018 21:58

Need to handle a designer event...

All Replies

Posted by Community Admin on 06-Feb-2011 00:00

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?

Posted by Community Admin on 06-Feb-2011 00:00

Also I'd like to know how to handle the callback after "Save" has been completed...I need to run a script

Posted by Community Admin on 07-Feb-2011 00:00

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.

This thread is closed