Sorttable ul li get order

My html is like this

<ul> <li>...</li> <li> <ul> <li>...</li> </ul> </li> </ul>

This is just a example, a ul can contain many li but the max depth is ul li ul like in example

I am using JqueryUI Sortable to sort this li I want to get the sort order of the li to store it in database so that user dont have to sort each time.

Thank You.

-------------Problems Reply------------

You'll have to bind the "sortupdate" event which you can use to update your database. The next time the page loads you have to sort the items serverside.

EDIT:

The following will bind the sortupdate event and post it to /story/reorder (www.asdf.com/sort/reorder?ids=somevalue&oldIds=anothervalue). That page will store it in the database.

You probably have to add another variable to pass the userid of the person who logged in.

$("#sortable").bind('sortupdate', function(event, ui) {
var ids = $("#sortable").sortable('serialize').toString();
$.post('/story/reorder', {ids: ids, oldIds: idsOldOrder}, function(data) {
// nothing special
window.alert(data);
});
idsOldOrder = ids;
});

Source: http://www.gridshore.nl/2009/09/14/creating-a-sortable-list-of-items-using-jquery/

Category:javascript Views:0 Time:2010-03-29

Related post

  • Exporting ISO date in Numpy 2011-11-02

    I am new in python and have a basic question I can not find a solution on the net. I have a table named IBTsample.txt, containing: Season,ISO_time,Latitude,Longitude,Enum 2009,2009-12-24 12:00:00,6.50,85.00,2 2009,2009-12-25 06:00:00,8.00,84.50,6 200

  • Change table-like items order 2009-11-27

    I have a set of divs table-like (with rows and cols), to display a soccer table. Now, I need to be able to order that table according to the key chosen, without refreshing the page and avoiding using ajax. Being more specific, I need to catch the val

  • C# logic order and compiler behavior 2008-08-07

    In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement? Example: DataTable myDt = new DataTable(); if (myDt != null && myDt.Rows.Count > 0) { //do some stuff with myDt } Which statement

  • Implementing an online ordering system for a restaurant/cafe 2008-08-07

    I would like to implement an online ordering system for restaurants. I am starting to research this a bit, and wanted to throw it out here. Is there any open source projects already started out there I could work with and contribute to? Would it be e

  • Run PHPUnit Tests in Certain Order 2008-08-13

    Is there a way to get the tests inside of a TestCase to run in a certain order? For example, I want to seperate the lifecycle of an object from creation to use to destruction but need to make sure that the object is set up first before I run the othe

  • How can you customize the numbers in an ordered list? 2008-08-14

    How can I left-align the numbers in an ordered list? 1. an item // skip some items for brevity 9. another item 10. notice the 1 is under the 9, and the item contents also line up Change the character after the number in an ordered list? 1) an item Al

  • Why does Guid.ToString() reverse the byte order? 2008-08-20

    We're storing some Guid's in a MS SQL database. There's some legacy code that does Guid.ToString() and then passes them in to a varchar(64) and there's some newer code that passes them in using a unique identifier parameter. When you look at the resu

  • JavaScript Load Order 2008-08-20

    Hey I am working with both amq.js (ActiveMQ) and Google Maps. I load my scripts in this order <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <title>AMQ & Maps Demo</title> <!-- Stylesheet --

  • Best way to keep an ordered list of windows (from most-recently created to oldest)? 2008-08-21

    What is the best way to manage a list of windows (keeping them in order) to be able to promote the next window to the top-level when the current top-level window is closed. This is for a web application, so we're using jQuery Javascript. We'd talked

  • SQL Group By with an Order By 2008-08-26

    I have a table of tags and want to get the highest count tags from the list. Sample data looks like this id (1) tag ('night') id (2) tag ('awesome') id (3) tag ('night') using SELECT COUNT(*), `Tag` from `images-tags` GROUP BY `Tag` gets me back the

  • Impose a total ordering on all instances of *any* class in Java 2008-08-26

    I'm unsure whether the following code would ensure all conditions given in Comparator's Javadoc. class TotalOrder<T> implements Comparator<T> { public boolean compare(T o1, T o2) { if (o1 == o2 || equal(o1, o2)) return 0; int h1 = System.

  • How to control layer ordering in Virtual Earth 2008-08-28

    I have a mapping application that needs to draw a path, and then display icons on top of the path. I can't find a way to control the order of virtual earth layers, other than the order in which they are added. Does anyone know how to change the z ind

  • XML Schema construct for "Any number of these elements - in any order" 2008-08-28

    I need to create an XML schema that looks something like this: <xs:element name="wrapperElement"> <xs:complexType> <xs:sequence> <xs:element type="el1"> <xs:element type="el2"> </xs:sequence> <xs:WhatGoesHere?

  • SQL Server - Does column order matter? 2008-08-29

    In terms of performance and optimizations: When constructing a table in SQL Server, does it matter what order I put the columns in? Does it matter if my primary key is the first column? When constructing a multi-field index, does it matter if the col

  • Order an Array like another Array in C# 2008-09-04

    I'm looking for the best algorithm to take array A {0,1,2,3} and make order it like array B {3,1,0,2}. Any ideas? --------------Solutions------------- So if you have two arrays and they hold the same data just in different order then just do this: A

  • How to set the order in subnodes of a tree structure 2008-09-06

    I have a tree representation of pages in a CMS application. I understand how to persist the tree in the database. However, I don't have a good way to: A) Reorder subpages under a particular parent page. B) Provide a UI implementation that allows the

  • Efficiently reverse the order of the words (not characters) in an array of characters 2008-09-06

    Given an array of characters which forms a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it. Example input and output: >>> reverse_words("this is a string") 'string a is this' It should

  • In what order are locations searched to load referenced DLLs? 2008-09-08

    I know that the .NET framework looks for referenced DLLs in several locations Global assembly cache (GAC) Any private paths added to the AppDomain The current directory of the executing assembly What order are those locations searched? Is the search

  • Comparing two collections for equality irrespective of the order of items in them 2008-09-08

    I would like to compare two collections (in C#), but I'm not sure of the best way to implement this efficiently. I've read the other thread about Enumerable.SequenceEqual, but it's not exactly what I'm looking for. In my case, two collections would b

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.074 (s). 11 q(s)