Jump to content

Recommended Posts

Hello, I have an interesting situation and I cannot determine what is wrong. I am trying to build a drag and drop category and product list. I am using jQuery UI's sortable function to do so. I am using the latest versions of jQuery and jQuery UI.

 

The lists are laid out as so:

<ul> // Top level categories

    <li>TLC 1

        <ul>Sub Category 1

          <li>Cat A</li>

          <li>Cat B</li>

      </ul>

    </li>

    <li>TLC 2

      <ul>Sub Category 2

          <li>Cat C</li>

          <li>Cat D</li>

      </ul>

    </li>

</ul>

 

My javascript is thus:

$(".admin-tree-sort-cat").sortable({
cancel: ".sort-button",
connectWith: ".admin-tree-sort-cat",
update: function(event, ui) {
	var ids = $(this).sortable("toArray").toString();
	$.ajax({
		type: "POST",
		url: "ajax/tree_order.php",
		data: { ids: ids, cat: "1" },
		success: function(data) {
			alert(data);
		}
	});
},
placeholder: "ui-state-highlight"
});

Dragging from sub-category to top level category works fine. Dragging from sub-category to sub-category works fine. However dragging from top level category to sub-category only triggers the update on the top level category, not the sub-category, which means the change doesn't get saved. Why would dragging from sub-category to tlc work but not the other way round?

 

Firebug shows no errors and all the correct ajax calls, except for the missing one when dragging from tlc to sub cat.

Link to comment
https://forums.phpfreaks.com/topic/261466-jquery-ui-sortable-update-not-firing/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.