Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#25594 closed defect (bug) (fixed)

When modifying your first menu, before saving, "Move" links do not work

Reported by: ericlewis's profile ericlewis Owned by: nacin's profile nacin
Milestone: 3.8 Priority: normal
Severity: normal Version: 3.6
Component: Menus Keywords: has-patch
Focuses: Cc:


Before you have saved your first menu, a draft menu is populated for you to use with all the pages on your site. If you click on the dropdown arrow to open up one of these items (assuming your site has multiple pages), there are "Move" links - 'Up one,' 'Down one,' 'Under Test page,' 'To the top'. These links don't work, at least until you save the menu.

Attachments (2)

nav-menu.patch (1.6 KB) - added by ankit.gade@… 10 years ago.
Menu move jQuery patch
25594.jshint.diff (964 bytes) - added by atimmer 10 years ago.

Download all attachments as: .zip

Change History (9)

10 years ago

Menu move jQuery patch

#1 @ankit.gade@…
10 years ago

  • Cc ankit.gade@… added
  • Keywords has-patch added

In wp-admin/js/nav-menu.js file the events are attached to the element on "onclick" event. So evets are attched to the element when the page gets loaded, but not to the elements which are getting added to the document dynamically. So appropriate selector should be there, So instead of adding $("#element").on('click', function(){}) it should be $('body').on('click', "#element" function(){}). By doing this change it will work for all the targeted elements which are present or getting added dynamically after the page load.

#2 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 3.8
  • Version changed from trunk to 3.6

#3 @azaozz
10 years ago

Yes, delegating the click would work for all elements, initially loaded and added later. A bit better/faster way to do this would be to add one event handler and check the target:

$(document).on( 'click.move-menu', function( event ) {
  var $target = $( );

  if ( $target.hasCLass('menus-move-up') ) {
  } else if ( $target.hasCLass('menus-move-down') ) {
  } else if ( ... )
Last edited 10 years ago by azaozz (previous) (diff)

#4 @nacin
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 26613:

Nav Menus: Delegate click events for move links.

props ankit.gade.
fixes #25594.

#5 @atimmer
10 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

[26613] introduces 3 new jshint errors, 25594.jshint.diff fixes this.

#6 @nacin
10 years ago

Those were a mistake on my part, I had removed them to chain these, then decided against. Thanks.

#7 @nacin
10 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 26623:

Return some semicolons. fixes #25594.

Note: See TracTickets for help on using tickets.