Open maximilianh opened 7 years ago
If I'm right, you set change event function as option by init. It means you have to know current DOM elm, which you set spectrum for, don't you? Than it's easy to use current elm right in change fallback.
I found by experience that the this
object inside the change event handler is the input DOM element. You can use this to reference the current color picker.
If you want to access the spectrum API methods inside the event handlers callback, you can access by $(this).spectrum('desired method')
.
I believe this could be add to the documentation page in order to help others like me and you.
Yes it would be great if "this" could be documented. I worked around it with a cludge but would have loved to use it.
Came across the problem again, found this answer, was happy to find it, then discovered my own comment from a year ago. Stupid brains.
I have 50 color pickers in my application, created in a for-loop. It would be nice if the change event handler could find out from which DOM element (= which color picker) the event is coming. Currently, all the change handler gets is the color. This could be easily hacked to the current system by adding a _target attribute to the color or maybe cleaner by throwing another event, changeElement or something similar.
But maybe I'm missing something, is there an easy solution for this problem with the current color picker?