Skip to content

Re-use instance methods #6

@Tim-Wils

Description

@Tim-Wils

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;
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions