enqueue script during add menu items means before save menu items

I’m extended the Walker_Nav_Menu_Edit class and added some new custom fields based on some jQuery plugins like (wpColorPicker, fonIconPicker, and Select2). I’m called these functions from different js file like below

jQuery.(document).ready(function() {
$(‘.hpemenu-fonticons’).fontIconPicker();
$(‘.fonticons-iconwpcolorpicker’).wpColorPicker();
$(“.bsnselect”).select2();
});

Then I enqueued this js file over my WordPress admin area by using admin_enqueue_scripts action.

When I add new menu item from Custom Link panel, these functions not work until I Click on Save Menu button to save menu item, After saving menu item and reload the nav-menus.php all functions work without the problem.

INFO: When I use jQuery functions inside the Walker_Nav_Menu_EditClass (Means not in separate js file) inside tag all functions work before saving menu item.

How can I call js file inside the Walker_Nav_Menu_Edit? Or how can I trigger js file codes during adding custom link items before saving menu items?

Read more here:: enqueue script during add menu items means before save menu items

Leave a Reply

Your email address will not be published. Required fields are marked *