Skip to content

Possible to determine element from color:change etc. #245

@moracca

Description

@moracca

When referencing a ColorPicker instance, we can call the el method on the object to get the HTML element that the color picker was mounted to. When we add callbacks to the color picker, for example color:change or input:end, we are passed a Color instance, that has properties describing the current color state of the picker.

My question however, is whether it is possible to determine within the callback function which ColorPicker this Color object corresponds to? The end goal being to grab some data-* attributes from the HTML element the color picker was mounted to in order to perform some action that is specific to this color picker (as opposed to other color pickers which may be rendered on the same page). Can this be done? I can't find a way to reference the element or ColorPicker instance from the Color instance, and don't see it listed in the Colors API, but it seems that this would be a common use case, so perhaps I am missing something.

Thanks!

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