Opened 12 years ago
Last modified 5 years ago
#21171 new enhancement
jQuery Events for Metaboxes
Reported by: | WraithKenny | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | |
Component: | Administration | Keywords: | needs-patch |
Focuses: | javascript | Cc: |
Description
Currently, when a plugin adds a metabox with complex objects (like TinyMCE, Maps, CodeMirror etc) care must be taken to refresh the objects when the elements are moved (including hidden/shown).
After some digging, I've found that this seems to works in most cases:
var context = "#custom_meta_box_id"; $( '#adv-settings' ).on( 'click', context + '-hide, ', refresh ); $( context ).on( 'click', '.hndle, .handlediv', refresh ); $('.meta-box-sortables').bind( "sortstop", refresh );
which isn't terrible, but seems fragile if core changes in the future, and there should just be a better way :-)
Two ideas from dev chat are triggering custom events or the (coming soon) "js actions" which would be more robust (like php actions).
Change History (3)
Note: See
TracTickets for help on using
tickets.
Related: #21170