Select2 jQuery code work after Saving Menu in WordPress menu items

298
August 20, 2017, at 08:05 AM

I have WordPress theme i added the new select box based on select2 plugin. When i add new menu item before click on Save Menu button don't apply the select2 jquery code over the select box. But after click on Save Menu directly applied select2 jquery code over the select box

More info from this image below

The image show the select2 select box before click on Save Menu button and after click on Save Menu button

This is my jquery code from js file

$(".bsnselect").select2({
    placeholder: "Select ...",
    width: '100%',
    minimumResultsForSearch: Infinity,
    theme: "classic"
});

This code from a php file for enqueue the select2 files

function YPE_bsn_backend() {
    wp_enqueue_script( 'select2-js', plugins_url( '/js/select2.min.js', __FILE__ ), array( 'jquery' ), null, true );
}
add_action( 'admin_enqueue_scripts', 'YPE_bsn_backend' );
function YPE_bsn_backend() {
    wp_enqueue_style( 'select2-css', plugins_url( '/css/select2.min.css', __FILE__ ) );
}
add_action( 'admin_enqueue_scripts', 'YPE_bsn_backend' );
Rent Charter Buses Company
READ ALSO
Multiple actions on a Single Change Event with JQuery/Javascript

Multiple actions on a Single Change Event with JQuery/Javascript

I need to implement this js in order to fill in different fields on change event of a select field

244
Error 500 on Ajax Call

Error 500 on Ajax Call

So I am developing a website where users can write articlesI'm coming across a problem

360
Issue with Chrome and Select boxes and option size

Issue with Chrome and Select boxes and option size

I've noticed an issue recently with Chrome and Select boxesThe size of the options has got much larger and there appears to be extra padding

262
Dynamically add & remove rows

Dynamically add & remove rows

I have 2 different table in same page2 table having functionality that dynamically add & remove rows

253