Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#4325 closed bug (notabug)

sortable fires sortupdate-event twice

Reported by: MMore Owned by:
Priority: minor Milestone:
Component: ui.sortable Version: 1.7
Keywords: sortupdate encapsulated list Cc: [email protected]
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?

Change History (3)

comment:1 Changed 14 years ago by jakeisonline

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.

comment:2 Changed 14 years ago by Jörn Zaefferer

Resolution: invalid
Status: newclosed

See comment by jakeisonline.

comment:3 Changed 11 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.