How to refresh Theme Customizer after change color inside wpColorPicker?


I develop my custom widget with setting where I can set up custom color for the widget. I use this code to initialize wpColorPicker instead of default text input in form() method of Widget class:

    $('#<?php echo $this->get_field_id( 'bg_color_1' ); ?>').wpColorPicker();

All works great but if you are trying change the color in Theme Customizer after changing value nothing happens: the Save button still not active and site page not refreshing with the new color.

Previously trying for triggering change event, but not working:

$('#<?php echo $this->get_field_id( 'bg_color_1' ); ?>').wpColorPicker({
    change: function(event, ui) {
        $('#<?php echo $this->get_field_id( 'bg_color_1' ); ?>').change();

How to reload the page preview (trigger the event when value inside my input have been changed)?

, , , Kolya Korobochkin 4 years 2020-02-15T08:39:17-05:00 0 Answers 70 views 0

Leave an answer