0

I echo some <li class='A'> or class='B' or class='C' in #a sortable div. Then user moves them in #b sortable div. I need that in #b the <li> automaticly sort themselves by desc alfabetic order of their class (C->B->A) and, in second time, by alfabetic order of the <li>'s content (<li class='X'>content</li>).

How have I to script in <head>?

Kara
  • 6,115
  • 16
  • 50
  • 57
Tom
  • 11
  • 7

1 Answers1

0

jQuery UI has nice sortable stuff. Here are the demos.

Try using the update event to enforce your ordering.

$( ".selector" ).sortable({
 update: function(event, ui) {
   $("find the LIs you want").sort(
     function(a, b){
       var aName = a.name.toLowerCase();
       var bName = b.name.toLowerCase(); 
       return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
    });
 }
});

The sort code is from this answer.

Community
  • 1
  • 1
bluevector
  • 3,485
  • 1
  • 15
  • 18