2013-10-11 111 views
0

这里是我的小提琴:http://jsfiddle.net/2vtDj/1/禁用jQuery的可拖动后KEYUP

眼下盒是可拖动的,但我想文本输入到输入框后,他们是UNdraggable。

jQuery的我一直在搞乱:

// tried 'disable', and just #sortable without li 
    $("#sortable > li").draggable('destroy'); 

全码:

$('input').keyup(function() { 
filter(this); 

}); 

function filter(element) { 
var value = $(element).val(); 

$("#sortable > li").each(function() { 
    if ($(this).text().toLowerCase().indexOf(value) > -1) { 
     $(this).show(); 
     $(".number").show(); 
     $(".numberstwo").show(); 
     $("#sortable > li").draggable('destroy');  

     // $('#sortable').addClass("destory"); 


    } else { 
     $(this).hide(); 
     $(".number").hide(); 
     $(".numberstwo").hide(); 
     $(".games").css("padding-top", "40px"); 

    } 
}); 
} 

回答

2
$("#sortable").sortable({ 
    revert: true, 
    placeholder: "dashed-placeholder" , 
    cancel: '.canceled' // <-----add this option 
}); 

$("#sortable > li").each(function() { 
    if ($(this).text().indexOf(value) > -1) { 
     $(this).show(); 
     $(".number").fadeOut(); 
     $(".numberstwo").fadeOut(); 
     $(this).addClass('canceled'); // <---- add 
    } else { 
     $(this).hide(); 
     $(".number").show(); 
     $(".numberstwo").show();   
     $(this).removeClass('canceled'); // <---- add 
    } 
}); 
+0

哼。不适合我在本地或在jsfiddle工作。还有其他建议吗? – evan

+0

@edawg - '可排序'您是否维护? – babonamu

+0

我用排序,正确。 #sortable是我的ID。 – evan