Javascript 键控后禁用jQuery可拖动
这是我的小提琴: 现在,这些框是可拖动的,但我希望在文本输入框中后,它们是不可拖动的 我一直在处理的jQuery:Javascript 键控后禁用jQuery可拖动,javascript,jquery,html,jquery-ui,Javascript,Jquery,Html,Jquery Ui,这是我的小提琴: 现在,这些框是可拖动的,但我希望在文本输入框中后,它们是不可拖动的 我一直在处理的jQuery: // tried 'disable', and just #sortable without li $("#sortable > li").draggable('destroy'); 完整代码: $('input').keyup(function() { filter(this); }); function filter(element) {
// 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");
}
});
}
$(“#可排序”).sortable({
回复:对,
占位符:“虚线占位符”,
取消:'.已取消'/-1){
$(this.show();
$(“.number”).fadeOut();
$(“.numbers2”).fadeOut();
$(this).addClass('cancelled');//嗯。在本地或JSFIDLE中对我不起作用。还有其他建议吗?@edawg-'Sortable'您维护吗?是的,这很有效!但是有了keyup,它就不会再出现了。我会继续使用它,谢谢。
$("#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
}
});