Try our conversational search powered by Generative AI!

Register a event listener to Open/Close widget

Vote:
 

I would like to be able to execute code when the user opens (expands) or closes (compress) a Dijit-widget in the widget/gadget list in Edit mode (the ComponentPaneContainer ?).

Trying to add this.on('click', function(e) { ... }); in postCreate-function of the widget only gives a possibility to run code when the user clicks IN the widget. I need to know when the widget is closed or opened, that is when the user clicks on the gadget title.

Is this possible and if yes - how can it be done?

#64708
Jan 07, 2013 17:26
Vote:
 

Well, there's currently no perfect solution for this. What you can do is watch the open property of your parent container, so in startup do something like this:

    var handle, parent = this.getParent();
    while (parent && !(parent instanceof _ComponentWrapper)) {
        parent = parent.getParent();
    }
    if (parent) {
        // Keep a reference to the watch handle so it can be removed when destroying the widget. 
        handle = parent.watch("open", function (name, oldState, newState) {
            console.log("Is open:", newState);
        });
    }

where _ComponentWrapper is a reference to epi/shell/widget/layout/_ComponentWrapper.

This is a bit hacky since it assumes a bit too much about the widget's surroundings.

#64724
Jan 08, 2013 11:15
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.