Search and Top Navigation
#4325 closed bug (notabug)
Opened March 11, 2009 11:48PM UTC
Closed May 07, 2009 11:02AM UTC
Last modified October 11, 2012 09:15PM UTC
sortable fires sortupdate-event twice
Reported by: | MMore | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ui.sortable | Version: | 1.7 |
Keywords: | sortupdate encapsulated list | Cc: | mathias.nestler@gmail.com |
Blocked by: | Blocking: |
Description
When you have an unordered encapsulated list. And you want to sort two parts of it. When you sort the nested node the sortupdate-event fires twice.
For instance you have such a list:
<ul id="menulist"> <li id="mainmenu_1" class="mainmenuitem">Start <ul class="submenulist"> <li id="submenu_9">Home</li> <li id="submenu_7">Homer</li> <li id="submenu_6">Homest</li> </ul> <ul> <li id="mainmenu_2" class="mainmenuitem">Foobar <ul class="submenulist"> <li id="submenu_5">Host</li> <li id="submenu_4">Hoster</li> </ul> <ul>
"Start" and "Foobar" is the first part. In their nested nodes is the second part of the encapsulated list.
And this jquery code:
$(\\"#menulist:not(.submenulist)\\").sortable({ items: 'li.mainmenuitem' }); $(\\".submenulist\\").sortable(); $(\\"#menulist:not(.submenulist)\\").bind(\\"sortupdate\\",function(event,ui){ var order = $(this).sortable('serialize'); $.get(\\"menu.order.php\\",order); }); $(\\".submenulist\\").bind(\\"sortupdate\\",function(event,ui){ var order = $(this).sortable('serialize'); $.get(\\"submenu.order.php\\",order); });
For example, when you sort "hoster" above "host" the sortupdate-event of .submenulist and #menulist:not(.submenulist) are fired.
Is it a bug or feature? Or a false approach?
This isn't a bug, it's supposed to call them both because both of the lists have been updated, hence the callback name of "update".
If you want it to just trigger once, best used "receive" event callback.