Home Forums Bug Reports Select2 not initializing when adding new items to menu


Select2 not initializing when adding new items to menu

  • Steps to reproduce:

    1) Create a field group assigned to “menu items”.
    2) Include a select field in the group, with “Stylised UI” enabled (Also worth noting that Stylized is apparently spelled wrong in the plugin?)
    3) Go to the WordPress menu manager and add a new item to a menu.

    Wrong behavior:

    Select fields on new menu items will not have the Select2 library initialized on them until the menu is saved and the page is refreshed.

    I was alerted to this issue from a user of my ACF FontAwesome plugin which also uses Select2 and is experiencing the same bug. If I find a fix for the problem in my plugin, I will update here with what I find.

  • The fix I found for my ACF addon uses an event that WordPress triggers after a new menu item has been added.

    Location: /wp-admin/js/nav-menu.js Line #1017
    Event: menu-item-added

    The event passes along the new menu item markup, which can then be searched for any select fields with stylized UI and initialized if found.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.