Make WordPress Core

Opened 12 years ago

Last modified 5 years ago

#21171 new enhancement

jQuery Events for Metaboxes

Reported by: wraithkenny's profile 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)

#1 @scribu
12 years ago

Related: #21170

#2 @DrewAPicture
9 years ago

  • Component changed from General to Administration
  • Focuses javascript added

Related: #19173

#3 @wonderboymusic
9 years ago

  • Keywords needs-patch added
  • Type changed from feature request to enhancement
Note: See TracTickets for help on using tickets.