
Creates an interface for drag and drop sorting of a list or lists.
new Sortables(list[, options]);
Fired when the item starts dragging.
onStart(element, clone)
Fired when the item is inserted into a new place in one of the lists.
onSort(element, clone)
Fired when the item ends dragging. Note: fires even if the sort has not changed.
onComplete(element)
var mySortables = new Sortables('list-1', { revert: { duration: 500, transition: 'elastic:out' } }); //creates a new Sortable instance over the list with id 'list-1' with some //extra options for the revert effect var mySortables = new Sortables('#list-1, #list-2', { constrain: true, clone: false, revert: true }); //creates a new Sortable instance allowing the sorting of the lists with //ids 'list-1' and 'list-2' with extra options since constrain was set to //true, the items will not be able to be dragged from one list to the other var mySortables = new Sortables('#list-1, #list-2, #list-3'); //creates a new Sortable instance allowing sorting between the lists with //ids 'list-1', 'list-2, and 'list-3'
Attaches the mouse listener to all the handles, enabling sorting.
mySortables.attach();
Detaches the mouse listener from all the handles, disabling sorting.
mySortables.detach();
Allows one or more items to be added to an existing Sortables instance.
mySortables.addItems(item1[, item2[, item3[, ...]]]);
var mySortables = new Sortables('#list1, #list2'); var element1 = new Element('div'); var element2 = new Element('div'); var element3 = new Element('div'); $('list1').adopt(element1); $('list2').adopt(element2, element3); mySortables.addItems(element1, element2, element3);
Allows one or more items to be removed from an existing Sortables instance.
mySortables.removeItems(item1[, item2[, item3[, ...]]]);
var mySortables = new Sortables('#list1, #list2'); var element1 = $('list1').getFirst(); var element2 = $('list2').getLast(); mySortables.removeItems(element1, element2).destroy(); //the elements will be removed and destroyed
Allows one or more entire lists to be added to an existing Sortables instance, allowing sorting between the new and old lists.
mySortables.addLists(list1[, list2[, list3[, ...]]]);
var mySortables = new Sortables('list1'); mySortables.addLists($('list2'));
Allows one or more entire lists to be removed from an existing Sortables instance, preventing sorting between the lists.
mySortables.removeLists(list1[, list2[, list3[, ...]]]);
var mySortables = new Sortables('#list1, #list2'); mySortables.removeLists($('list2'));
Function to get the order of the elements in the lists of this sortables instance. For each list, an array containing the order of the elements will be returned. If more than one list is being used, all lists will be serialized and returned in an array.
mySortables.serialize(index[, modifier]);
mySortables.serialize(1); //returns the second list serialized (remember, arrays are 0 based...); //['item_1-1', 'item_1-2', 'item_1-3'] mySortables.serialize(); //returns a nested array of all lists serialized, or if only one list exists, that lists order /*[['item_1-1', 'item_1-2', 'item_1-3'], ['item_2-1', 'item_2-2', 'item_2-3'], ['item_3-1', 'item_3-2', 'item_3-3']]*/ mySortables.serialize(2, function(element, index){ return element.getProperty('id').replace('item_','') + '=' + index; }).join('&'); //joins the array with a '&' to return a string of the formatted ids of all the elmements in list 3,with their position //'3-0=0&3-1=1&3-2=2'
© Linux.ria.ua, 2008-2024 |