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

JS Error: Uncaught Error: Syntax error, unrecognized expression #8

Open
michaelrimbach opened this issue Jun 8, 2018 · 1 comment

Comments

@michaelrimbach
Copy link

Hi,

first of all thanks for the plugin.

I tried to use it within a "group" field. After selecting a value over the ajax search dropdown, Im getting this JS error message:

load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2 Uncaught Error: Syntax error, unrecognized expression: input[name=prefixdemo[0][prefixasfd]]

at Function.fa.error (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at fa.tokenize (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at fa.select (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at Function.fa (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at Function.a.find (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:9)
at n.fn.init.find (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at n.fn.init.a.fn.find (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:9)
at a.fn.init.n.fn.init (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)
at new a.fn.init (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:9)
at n (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-position,jquery-ui&load[]=-tooltip&ver=4.9.5:2)

The value not getting saved. Maybe its because of the generated input name (input[name=prefixdemo[0][prefixasfd]])?

My code is:

add_action( 'cmb2_admin_init', 'yourprefix_register_repeatable_group_field_metabox' );
/**
 * Hook in and add a metabox to demonstrate repeatable grouped fields
 */
function yourprefix_register_repeatable_group_field_metabox() {
  $prefix = 'prefix';

  /**
   * Repeatable Field Groups
   */
  $cmb_group = new_cmb2_box( array(
    'id'           => $prefix . 'metabox',
    'title'        => esc_html__( 'Recommendation Products (4)', 'cmb2' ),
    'object_types' => array( 'landingpage' ),
  ) );

  // $group_field_id is the field id string, so in this case: $prefix . 'demo'
  $group_field_id = $cmb_group->add_field( array(
    'id'          => $prefix . 'demo',
    'type'        => 'group',
    'description' => esc_html__( 'Generates reusable form entries', 'cmb2' ),
    'options'     => array(
      'group_title'   => esc_html__( 'Product {#}', 'cmb2' ), // {#} gets replaced by row number
      'add_button'    => esc_html__( 'Add Another Product', 'cmb2' ),
      'remove_button' => esc_html__( 'Remove Product', 'cmb2' ),
      'sortable'      => true,
      // 'closed'     => true, // true to have the groups closed by default
    ),
  ) );

  /**
   * Group fields works the same, except ids only need
   * to be unique to the group. Prefix is not needed.
   *
   * The parent field's id needs to be passed as the first argument.
   */
  $cmb_group->add_group_field( $group_field_id, array(
    'name'          => __( 'Product', 'cmb2' ),
    'desc'          => __( 'Field description (optional)', 'cmb2' ),
    'id'            => $prefix . 'asfd',
    'type'          => 'post_ajax_search',
    'query_args'  => array(
      'post_type'     => array( 'product' ),
      'post_status'   => array( 'publish' ),
      'posts_per_page'  => -1
    )
  ) );

  $cmb_group->add_group_field( $group_field_id, array(
    'name'        => esc_html__( 'Description', 'cmb2' ),
    'description' => esc_html__( 'Write a short description for this entry', 'cmb2' ),
    'id'          => 'description',
    'type'        => 'textarea_small',
  ) );

  $cmb_group->add_group_field( $group_field_id, array(
    'name' => esc_html__( 'Entry Image', 'cmb2' ),
    'id'   => 'image',
    'type' => 'file',
  ) );

}
@sebastillar
Copy link

Thanks for this plugin!

Same issue here.

:(

Any solution?

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

2 participants