Disable on specific selectors, odd inside postbox behavior
-
Select dropdowns inside .postbox selectors get initialized when firing the postbox-toggled event. That means that on first pageload of a post edit backend page, a select dropdown inside a postbox will not get chosen initialized. However, after closing and opening the postbox, chosen gets initialized. This can be considered an odd behavior.
As a sidenote for this: it might not be a good idea to destroy and re-initialize on each dropdown each time a postbox is toggled. I have solved similar ptoblems by:
* checking that the postbox being toggled holds the classname closed or not.
* adding a flag classname to the select item when initializing the script so this only happens just once.In addition, I would propose having a classname that could be used as a selector to prevent initialization. Some plugins include select2 as a helper library on specific dropdowns, and when they belong to a postbox container, closing and opening the box means that a single select2 instance becomes a chosen instance followed by the select2 one. In short, targetting all dropdowns inside a postbox without a way to opt out might not be a good idea.
- The topic ‘Disable on specific selectors, odd inside postbox behavior’ is closed to new replies.