Mam taki skrypt: http://www.shopdev.co.uk/blog/sortable-lis...sing-jquery-ui/
Nie wiem jak zmienić ul i li na div. Próbowałem zmieniać ale nie działało. Proszę o pomoc.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> div { border:1px solid #DADADA; background-color:#EFEFEF; padding:3px 5px; margin-bottom:3px; margin-top:3px; list-style-type:circle; font-family:Arial, Helvetica, sans-serif; color:#666666; font-size:0.8em; } div:hover { background-color:#FFF; cursor:move; } </style> <script type="text/javascript"> ///////////////////////////////////////////////////////////////// ///// EDIT THE FOLLOWING VARIABLE VALUES ////////////////////// ///////////////////////////////////////////////////////////////// // set the list selector var setSelector = "#list1"; // set the cookie name var setCookieName = "listOrder"; // set the cookie expiry time (days): var setCookieExpiry = 7; ///////////////////////////////////////////////////////////////// ///// YOU PROBABLY WON'T NEED TO EDIT BELOW /////////////////// ///////////////////////////////////////////////////////////////// // function that writes the list order to a cookie function getOrder() { // save custom order to cookie $.cookie(setCookieName, $(setSelector).sortable("toArray"), { expires: setCookieExpiry, path: "/" }); } // function that restores the list order from a cookie function restoreOrder() { var list = $(setSelector); if (list == null) return // fetch the cookie value (saved order) var cookie = $.cookie(setCookieName); if (!cookie) return; // make array from saved order var IDs = cookie.split(","); // fetch current order var items = list.sortable("toArray"); // make array from current order var rebuild = new Array(); for ( var v=0, len=items.length; v<len; v++ ){ rebuild[items[v]] = items[v]; } for (var i = 0, n = IDs.length; i < n; i++) { // item id from saved order var itemID = IDs[i]; if (itemID in rebuild) { // select item id from current order var item = rebuild[itemID]; // select the item according to current order var child = $("div.ui-sortable").children("#" + item); // select the item according to the saved order var savedOrd = $("div.ui-sortable").children("#" + itemID); // remove all the items child.remove(); // add the items in turn according to saved order // we need to filter here since the "ui-sortable" // class is applied to all ul elements and we // only want the very first! You can modify this // to support multiple lists - not tested! $("div.ui-sortable").filter(":first").append(savedOrd); } } } // code executed when the document loads $(function() { // here, we allow the user to sort the items $(setSelector).sortable({ axis: "y", cursor: "move", update: function() { getOrder(); } }); // here, we reload the saved order restoreOrder(); }); </script> </head> <body> <div class="list"> </div> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> div#list { border:1px solid #DADADA; background-color:#EFEFEF; padding:3px 5px; margin-bottom:3px; margin-top:3px; list-style-type:circle; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:0.8em; } div:hover { background-color:#FFF; cursor:move; } .sortHelper { border: 2px dotted #666; margin: 2px 0px 2px 0px; padding-bottom:0px; padding-top:0px; background-color: #ffffff; width: auto !important; } </style> <script type="text/javascript"> ///////////////////////////////////////////////////////////////// ///// EDIT THE FOLLOWING VARIABLE VALUES ////////////////////// ///////////////////////////////////////////////////////////////// // set the list selector var setSelector = "#list"; // set the cookie name var setCookieName = "listOrder"; // set the cookie expiry time (days): var setCookieExpiry = 7; ///////////////////////////////////////////////////////////////// ///// YOU PROBABLY WON'T NEED TO EDIT BELOW /////////////////// ///////////////////////////////////////////////////////////////// //getter var placeholder = $( ".sortHelper" ).sortable( "option", "placeholder" ); //setter $( ".sortHelper" ).sortable( "option", "placeholder", 'ui-state-highlight' ); // function that writes the list order to a cookie function getOrder() { // save custom order to cookie $.cookie(setCookieName, $(setSelector).sortable("toArray"), { expires: setCookieExpiry, path: "/" }); } // function that restores the list order from a cookie function restoreOrder() { var list = $(setSelector); if (list == null) return // fetch the cookie value (saved order) var cookie = $.cookie(setCookieName); if (!cookie) return; // make array from saved order var IDs = cookie.split(","); // fetch current order var items = list.sortable("toArray"); // make array from current order var rebuild = new Array(); for ( var v=0, len=items.length; v<len; v++ ){ rebuild[items[v]] = items[v]; } for (var i = 0, n = IDs.length; i < n; i++) { // item id from saved order var itemID = IDs[i]; if (itemID in rebuild) { // select item id from current order var item = rebuild[itemID]; // select the item according to current order var child = $("div.ui-sortable").children("#" + item); // select the item according to the saved order var savedOrd = $("div.ui-sortable").children("#" + itemID); // remove all the items child.remove(); // add the items in turn according to saved order // we need to filter here since the "ui-sortable" // class is applied to all ul elements and we // only want the very first! You can modify this // to support multiple lists - not tested! $("div.ui-sortable").filter(":first").append(savedOrd); } } } // code executed when the document loads $(function() { // here, we allow the user to sort the items $(setSelector).sortable({ axis: "y", cursor: "move", placeholder: "sortHelper", update: function() { getOrder(); } }); // here, we reload the saved order restoreOrder(); }); </script> </head> <body> <div id="list"> </div> </body> </html>