0
https://jsfiddle.net/scottbeeson/r5du4p6k/12/未捕獲錯誤:無法在初始化之前調用可拖動的方法;試圖調用方法「禁用」
如果長按拖動,當你釋放你得到以下錯誤:
Uncaught Error: cannot call methods on draggable prior to initialization; attempted to call method 'disable'
var t;
$(document).on('touchstart mousedown','.menu-item', function (event) {
var self = this;
if ($(self).hasClass('draggable')) return;
t = setTimeout(function() {
$(self).draggable({
revert: true,
helper: 'clone',
opacity: .75,
appendTo: 'body'
}).draggable('enable').addClass('draggable');
$(self).trigger(event)
}, 800);
});
$(document).on("touchend mouseup", function() {
clearTimeout(t);
$('.draggable').draggable('disable').removeClass('draggable');
});
哦,從拖動事件克隆?說得通。謝謝。 –
當然:)歡迎您! – Dekel
而不是使用'.first()'我用'$('#container .draggable')...'來限制範圍。這似乎更可靠。 –