#37069 closed defect (bug) (wontfix)
WP Color Picker has no appropriate disable / destroy method.
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.5.2 |
| Component: | General | Keywords: | |
| Focuses: | javascript, administration | Cc: |
Description
It seems WP Color Picker has no appropriate disable or destroy method.
You can do
colorPicker.wpColorPicker('option','disabled', true);
Nothing happens except it adds wp-wpColorPicker-disabled class. The color picker works like it is in normal state.
The same thing happens with destroy method, you can do
colorPicker.wpColorPicker('destroy');
And nothing happens here, too.
Change History (4)
This ticket was mentioned in Slack in #core by noisysocks. View the logs.
6 years ago
#4
@
23 months ago
what I made to make this work, only this code:
$( DIV SELECTOR ).find( '.YOUR INPUT CLASS NAME' ).each( function() {
var t = $( this );
t.removeClass( 'wp-color-picker' );
var t_clone = t.clone();
var t_color_picker = t.parent().parent().parent();
if ( t_color_picker.hasClass( 'wp-picker-container' ) ) {
t_color_picker.before( t_clone );
t_color_picker.detach();
}
} );
Note: See
TracTickets for help on using
tickets.
Thanks for the suggestion @Aniruddh !
wpColorPicker is currently in maintenance mode so we're not adding enhancements/new features to it. Instead, we encourage you to try out our new color picker component over in the Gutenberg repo: https://github.com/WordPress/gutenberg/tree/master/packages/components/src/color-picker