I am using Sortable jQuery UI to allow users to drag and drop rows of a table. This allows users to rank items in a table based on their preferences. After the user has finished ordering their list, they press the save button, which makes an Ajax call. The new rank is stored in the database, and the table is highlighted briefly.
Now I have added an extra button that will send the item right to the top of the list. This is also ajax. It works very well, except that I would like to add a transition effect when <tr> breaks off and drags itself to the top of the table, and click the following lines down. Is it possible? Here is the code I'm using:
This code processes the call to save changes to the database from the drag and drop function:
<input type="button" value="Save Queue" id="saveButton" class="list-button"> $(document).ready(function(){ $("#sortable").sortable(); $("#saveButton").click(persist); }); // Persist function (save order) function persist() { var data = $("#sortable").sortable('toArray'); $.ajax({ traditional: true, url: "/gz/index.cfm/membros/rankListByAjax?order="+data, type: "POST", success: function(msg){ $("#sortable tr").effect("highlight", {}, 1000); } }); }
The following code is the new send-item-to-top button that I added. This is when I want the transition to occur:
<form ...onsubmit=" $.ajax({ dataType: 'script', type: 'post', url: '/gz/index.cfm?controller=membros&action=send-item-to-top&key=1082&format=js&modType=replace', data: $(this).serialize(), success: function(data, textStatus){$(this).attr('disabled','false');}, beforeSend: function(XMLHttpRequest){$(this).attr('disabled','true');}}); return false;" text="↑">
jquery
Mohamad
source share