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

Add Fourth Argument to Callback Function #7

Open
mikebronner opened this issue May 4, 2014 · 1 comment
Open

Add Fourth Argument to Callback Function #7

mikebronner opened this issue May 4, 2014 · 1 comment

Comments

@mikebronner
Copy link

I would like to refence the calling colorSelector object from within the callback function, something like this:

    $('.colorSelector').colorselector({
        callback: function (value, color, title) {
            $($(this).id + 'Text').val(title);
            console.log($(this))
        }
    });

This way I don't have to register a callback function for each and every color selector separately, but can instantiate them all through a single function. (Or is there a better way, that I missed?) :) Thanks!

@maxsharov
Copy link

maxsharov commented Jan 11, 2018

I did it this way:
was

.css("background-color",a),o(e,a,l)}),l.on("click.colorselector",t.proxy(this._clickColor,this))}

became

.css("background-color",a),o(e,a,l,t(this))}),l.on("click.colorselector",t.proxy(this._clickColor,this))}

And now you can use callback function this way:

    $('.colorSelector').colorselector({
        callback: function (value, color, title, el) {
            console.log($(el)) // <-- your display:none .colorSelector element
        }
    });

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

2 participants