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

element which triggers the color chooser , and which we passed to onSelect callback is not retrieving the correct id #19

Open
hotcoder opened this issue May 19, 2014 · 1 comment
Assignees

Comments

@hotcoder
Copy link

Lets consider we have two html elements like below

and simpleColor javascript code is like below

$('.themeselector').simpleColor({
    cellWidth : 9,
    cellHeight : 9,
    onSelect : function(hex, element) {
        var elementId = element.attr("id");
                   alert(elementId);
    }
});

and let's second element with id "tcolor" trigger the color chooser then in the onselect call back the alert method in alerting the first element id , not the second element id , which triggers the chooser , and if we observe the "element" , which we pass is the array of elements which have that selector ,not the element which triggers the chooser.

mcdemarco added a commit to mcdemarco/jquery-simple-color that referenced this issue Sep 4, 2014
The element variable has been set to the collection of onclickable
elements, so use the event.target to return the calling element
instead.  This is only what I needed, not a thorough fix.
@mcdemarco
Copy link

The fix to this is for the plugin to call the onSelect callback function with the local event.target or $(event.target) instead of the plugin's value for element. I'm not sure which was intended, what would be normal jQuery plugin behavior, or what similar issues may need fixing, so I don't have a patch. My fork uses event.target since that was enough of a fix for my needs.

@recurser recurser self-assigned this Aug 6, 2017
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

3 participants