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

Uncaught TypeError: $id(...).hide(...).farbtastic is not a function #333

Closed
jedrzejchalubek opened this issue May 27, 2015 · 6 comments
Closed

Comments

@jedrzejchalubek
Copy link

Getting error form js file: Uncaught TypeError: $id(...).hide(...).farbtastic is not a function and of course all js based repeatable UI elements dont work.

Wordpress: 4.2.2
CMB: dev-trunk

@jtsternberg
Copy link
Member

The only reason that would happen is if this condition: (typeof jQuery.wp === 'object' && typeof jQuery.wp.wpColorPicker === 'function') is false. This means the colorpicker is not enqueued or some other script is causing that script to not work. There is nothing in CMB2 that would cause this to occur.

@jedrzejchalubek
Copy link
Author

But on version CMB2 2.0.6 this error not appears. I replacing worpdress jquery with cdn, need to test this out. Thanks.

@jtsternberg
Copy link
Member

If you're replacing default WordPress scripts, there's not much I can do to help.

@michaeljpowell
Copy link

I get this same error when I'm on a custom options page (specifically with the file upload field). When it's within a page it appears to be working fine.

I am using the WP plugin version.

@EvanHerman
Copy link

I too was getting the same error using the version up here on GitHub and the version found in the WordPress plugin repo. Whenever I included a color picker field I was getting the same error as the OP.

This was on a fresh TwentyFifteen install with no other plugins installed/active.

Adding the following, just below colorpicker field definition, did the trick for me:

wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );

Example in the example-functions.php file:

/**
* Options fields ids only need
* to be unique within this option group.
* Prefix is not needed.
*/
$cmb_options->add_field( array(
    'name'    => __( 'Site Background Color', 'cmb2' ),
    'desc'    => __( 'field description (optional)', 'cmb2' ),
    'id'      => 'bg_color',
    'type'    => 'colorpicker',
    'default' => '#ffffff',
) );

wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );

It seems to only be the color picker field that's causing this issue.

Evan

@jtsternberg
Copy link
Member

Thanks for reporting. The issue should be addressed in 244d39f

pluginmirror-worker pushed a commit to wp-plugins/cmb2 that referenced this issue Jun 1, 2015
* Fix color-picker field not enqueueing the colorpicker script. ([#333](CMB2/CMB2#333))

git-svn-id: https://plugins.svn.wordpress.org/cmb2/trunk@1171878 b8457f37-d9ea-0310-8a92-e5e31aec5664
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants