views:

663

answers:

2

I have a list with class x and in that list is a number of lists with class y.

It is possible to drag an item from any of the sublists to any of the other sublists

It is also possible to arrange the order of the sublists themselves.

I'm struggling with the events which are fired through the sortable

Receive - only triggers when something is brought into a list from elsewhere (so no good for arranging items in sublists or for arranging the sublists themselves)

Update - seems to trigger multiple times when I drag an item from sublist A to sublist B (I assume as sublist A is being updated and sublist B is being updated).

I have a function in my JS which syncronises the current layout in the lists and sublists to the database and don't want to do this more than once at a time.

No combination of these events seems to give me the desired behaviour at all. Is this the right route to take? Or is there someway I can do a scheduled call to the Sync method which runs every 5 seconds or so to save changes and ignore the actual events themselves?

+1  A: 

You should use the stop event for updating the ordered list.

For example:

        $("#List .Items").sortable({
            stop: function(e, ui) { 
                // update items
            }
        });
Philippe Leybaert
A: 

Ace! Thanks a lot - that works a treat and only gets called once which is what I was after!

Thanks again!

Graeme