Skip to content

Making a field repeatable generates JS error because of missing sortable lib #1214

@slaFFik

Description

@slaFFik

Expected Behavior:

I want to be able to mark select field type as repeatable (supported according to wiki).

Actual Behavior:

I see this error:

Uncaught TypeError: $repeatables.sortable is not a function
    at Object.cmb.makeRepeatableSortable (cmb2.js?ver=2.5.1:1017)
    at HTMLDocument.cmb.init (cmb2.js?ver=2.5.1:63)
    at i (jquery.js?ver=1.12.4:2)
    at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
    at Function.ready (jquery.js?ver=1.12.4:2)
    at HTMLDocument.K (jquery.js?ver=1.12.4:2)

This breaks Add Row and other JS-based functionality.

Steps to reproduce (I have confirmed I can reproduce this issue on the develop branch):

  • Yep.

WordPress 5.0.3, clean develop branch.

CMB2 Field Registration Code:

add_action( 'cmb2_admin_init', 'yourprefix_register_theme_options_metabox' );
function yourprefix_register_theme_options_metabox() {

	$cmb = new_cmb2_box( array(
		'id'           => 'yourprefix_theme_options_page',
		'title'        => esc_html__( 'Theme Options', 'cmb2' ),
		'object_types' => array( 'options-page' ),
		'option_key'   => 'yourprefix_theme_options', // The option key and admin menu page slug.
		'icon_url'     => 'dashicons-palmtree', // Menu icon. Only applicable if 'parent_slug' is left empty.
	) );

	$cmb->add_field( array(
		                 'name'             => 'Test Select',
		                 'desc'             => 'Select an option',
		                 'id'               => 'wiki_test_select',
		                 'type'             => 'select',
		                 'show_option_none' => true,
		                 'default'          => 'custom',
		                 'options'          => array(
			                 'standard' => __( 'Option One', 'cmb2' ),
			                 'custom'   => __( 'Option Two', 'cmb2' ),
			                 'none'     => __( 'Option Three', 'cmb2' ),
		                 ),
		                 'repeatable'       => true,
	                 ) );
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions