Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-use instance methods #6

Open
Tim-Wils opened this issue Sep 16, 2011 · 0 comments
Open

Re-use instance methods #6

Tim-Wils opened this issue Sep 16, 2011 · 0 comments

Comments

@Tim-Wils
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant