Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Re-use instance methods #6

Open
divyan opened this Issue · 0 comments

1 participant

@divyan

I had a use-case where I had to re-use the instance of the LightFace modal.
Different ajax-based content / forms-items had to be saved, so my Add-button had to behave different with different requests.
clearButtons() was one of the methods I had to use, so I could add new Add-buttons with another eventlistener on it.

Maybe it's some use to anyone:

LightFace.implement({
    clearButtons: function(){
        console.log(this.buttons);
        Object.each(this.buttons, function(button) {
            button.removeEvents('click');
            button.getParent('label').removeEvents('mousedown');
            button.getParent('label').removeEvents('mouseup');
            button.getParent('label').destroy();
            button.destroy();
            delete button;
        });
        this.buttons = {};
        return this;
    },
    setTitle: function(html) {
        this.title.set('html',html);
        return this;
    },
    setContent: function(html) {
        this.messageBox.set('html',html);
        return this;
    },
    setWidth: function(value) {
        this.contentBox.setStyle('width',value);
        return this;
    },
    setHeight: function(value) {
        this.options.height = value;
        this.messageBox.setStyle('height',value);
        return this;
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.