Opened 10 years ago
Last modified 6 years ago
#28747 new defect (bug)
$.wpColorPicker cannot duplicate elements
Reported by: | KingYes | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.1 |
Component: | Widgets | Keywords: | needs-patch |
Focuses: | javascript | Cc: |
Description
I can't clone()
wrap div
when I use with wpColorPicker
. If I just running the $.wpColorPicker
method again, I see two instance about this.
What I can to do for duplicate?
Change History (5)
#2
follow-up:
↓ 3
@
10 years ago
hey @westonruter.
When I just create a new instance for wpColorPicker like this: $( 'my-selector' ).wpColorPicker();
, and I duplicate this div with $.clone()
method. But with new html, the picker not works. So when I running $( 'my-new-selector' ).wpColorPicker();
again, I see two instance of the color picker.
Do you understand what I say?
Thanks,
Yakir.
#3
in reply to:
↑ 2
@
10 years ago
Replying to KingYes:
hey @westonruter.
When I just create a new instance for wpColorPicker like this:
$( 'my-selector' ).wpColorPicker();
, and I duplicate this div with$.clone()
method. But with new html, the picker not works. So when I running$( 'my-new-selector' ).wpColorPicker();
again, I see two instance of the color picker.
Do you understand what I say?
Thanks,
Yakir.
I think I understand. I think the problem is that using jQuery clone
is not copying the attached event handlers and data
attributes. So what I would recommend doing is upon cloning the container, that you then remove the color picker that was cloned and then re-initialize the color-picker on that element via $( clonedElement ).find( 'my-slector' ).wpColorPicker()
;
#4
@
10 years ago
It's very hard to remove the color wrapper. Maybe WP need added destroy
method for this task?
Please supply the PHP and JS code for the widget you are using.