jquery-palette-color-picker
jquery-palette-color-picker copied to clipboard
Get the name of the input in the change callback
Since I have more than a single colour picker in a page, I need in the onchange_callback the name of the corresponding input.
Now I get it with parent().parent() and all that jazz but I don't like too much... It would have been better to get it referenced directly...
Hi @pitommasi ... I know this could be a old question but I would answer anyway if you still need it...
I have managed with an event change. I fired it in the pallete's callback like this:
onchange_callback: function (clicked_color) { variables.color.trigger("change", [{"color": clicked_color}]); }
Where "color" is a variable name you decide.
And I get that value like this:
variables.color.on("change", function(e,data){ e.preventDefault(); var color = getColorName(data.color); graficarPorColor(color); });
Where data is what you sent trough fire in the callback. I hope it's what you need. Regards