• I’m trying to use the color picker in an admin menu. I tried the method described here:

    New Color Picker in WP 3.5

    But it doesn’t seem to be doing anything at all.

    Then I tried the method described here for WP 3.6: https://www.paulund.co.uk/adding-a-new-color-picker-with-wordpress-3-5

    And no luck there either.

    In the first method, the javascript file looks like this:

    jQuery(document).ready(function($){
        $('.my-color-field').wpColorPicker();
    });

    On the other site, that says it is for WP 3.6, it looks like this:

    $('.color-picker').iris();

    Does it matter if it is calling wpColorPicket() vs iris()?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    It depends on what page is loaded. Both libraries are part of the WP distribution and already registered, but they are loaded (enqueued) only on pages that use them. If you want to use them on a page that doesn’t normally load one or the other, you need to enqueue it yourself as a dependency for your own script. It’s actually a good idea (some say required) to specify the dependency of your script even if the library is loaded by other means.

    Also note that all jQquery script needs to use a noConflict wrapper (the jQuery(document).ready(function($){ }) part of your first example)

    Thread Starter thatposhgirl

    (@thatposhgirl)

    Thanks for the info. I fixed the script to use a noConflict wrapper, but still not doing anything.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wpColorPicker() vs iris()?’ is closed to new replies.