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

Reusing a widget or using it in multiple Pickr-instances #57

Open
4URGB opened this issue Jan 20, 2019 · 8 comments
Open

Reusing a widget or using it in multiple Pickr-instances #57

4URGB opened this issue Jan 20, 2019 · 8 comments
Labels
feature request New feature requested

Comments

@4URGB
Copy link

4URGB commented Jan 20, 2019

Hi,

i 've some input fields, and add the color-picker class to each of them.

Only the first input field, will work with the picker. Is that not possible to use your picker for multiple fields at same page or did i something wrong?

best regards,
Rene

@simonwep
Copy link
Owner

simonwep commented Jan 20, 2019

Hello :)

I think it's a duplicate of #30
Tried to reproduce it here but everything works fine. Could you provide a JSFiddle where this issue persist?
It's also helpful if you show me your browser(-version) and your current OS / environment.

@simonwep simonwep added the unconfirmed The problem isn't really clear label Jan 21, 2019
@simonwep
Copy link
Owner

simonwep commented Feb 9, 2019

Ah, I got what you mean, no. This is not possible, you need for each of your pickr-container an individual selector / Pickr instance.

@simonwep simonwep closed this as completed Feb 9, 2019
@simonwep simonwep added question Further information is requested and removed unconfirmed The problem isn't really clear labels Feb 9, 2019
@drkokai
Copy link

drkokai commented Aug 23, 2019

Hi,
Are you working on this implementation?

@simonwep
Copy link
Owner

@drkokai No, how should this get solved? How would you distinguish which event is from which instance? Use a for loop to archive something like this :)

@ange007
Copy link

ange007 commented Mar 6, 2020

@drkokai No, how should this get solved? How would you distinguish which event is from which instance? Use a for loop to archive something like this :)

Perhaps by storing a global match list?

Just like that, really bad:
image
Its many color picker elements (for edit many options in one time)

@simonwep
Copy link
Owner

simonwep commented Mar 6, 2020

@ange007 Reusing the overlay, could be possible if not always visible. I'll reopen this issue :)

@simonwep simonwep reopened this Mar 6, 2020
@simonwep simonwep added feature request New feature requested and removed question Further information is requested labels Mar 6, 2020
@simonwep simonwep changed the title multiple instances Reusing a widget or using it in multiple Pickr-instances Mar 6, 2020
@insad
Copy link

insad commented May 25, 2020

If you use only one picker at a time, it's rather easy to simulate the button and launch / destroy the color picker each time... using the same here in a big application, even built it out for setting gradients and showing more color swatches in groups and tabbed (material colors / bootstrap colors / theme colors... you name it)

@tarhkar
Copy link

tarhkar commented Sep 9, 2021

hi

Hi,

i 've some input fields, and add the color-picker class to each of them.

Only the first input field, will work with the picker. Is that not possible to use your picker for multiple fields at same page or did i something wrong?

best regards,
Rene

hi,
if Each element has a unique identifier you can use click function for get element ID and use it for select color example:
html :
<button type="button" id="1" class="color-picker">select color</button> <button type="button" id="2" class="color-picker">select color</button> <button type="button" id="3" class="color-picker">select color</button>
and js :
<script> jQuery(document).ready(function($){ $('.color-picker').click(function() { const ID = this.id; const inputElement = document.querySelector('#'+ID); const pickr = Pickr.create({ useAsButton: true, el: inputElement, ... }); }); }); </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature requested
Projects
None yet
Development

No branches or pull requests

6 participants