views:

484

answers:

1

Hi All , I want to disable sorting of source_element .how can i do so?

function dropMembers(){
        $("ul.present").sortable({
      connectWith: 'ul',
            containment: 'window',
            items: 'li:not(.notSortable)'
     });

     $("ul.usrlist").sortable({
      connectWith: 'ul',
      dropOnEmpty: true,
            containment: 'window',
            update: function(event, ui) {
                //Element ready to be dropped to new place
                   source_element = $(ui.item).attr("id");
                   alert(source_element);
                   source_element1=source_element.split('_');
                   alert(source_element1);
                   if(source_element[1]==GLOBAL_MY_ID){
                       // I want to disable sorting of source_element here
                   }
                   // here is your selected item  }
            }
//             sort: function(event, ui) {
//             var usr_result=$("ul.usr").sortable('toArray');
//             //alert(ui.sortable);
//            }
     });

     $("#MAIN_USER_LIST,#USER_PRESENT_LIST").disableSelection();

}
+2  A: 

In your example with code of my prevous answer to disable sorting use

$(ui.sender).sortable('cancel');

But I think, for disable movement better is prevent movement in start event and disable it as:

$(this).sortable('cancel');

P.S.: You create new question with my code without mark my answer as accepted. Dont understand your behavior..

Vitaly Dyatlov
agreed....all take but no give
redsquare
Thanks its done