My logic is
我的逻辑是
if( !this.draginited() ) // a drag-disabled element shouldn't get pass here, as it is inited
this.draggable({...})
I searched a lot and couldn't find a way to implement this logic, any ideas?
我找了很多,但是找不到实现这个逻辑的方法,有什么想法吗?
2 个解决方案
#1
12
Maybe there's an easier way, but the docs say:
也许有更简单的方法,但是医生说:
Draggable elements gets a class of ui-draggable
Draggable元素获得一个ui-draggable类
so you could do something like:
你可以这样做:
if(!$("#foo").hasClass("ui-draggable")) {
...
}
so to wrap that up (untested):
总结一下(未经测试)
$.fn.isDraggable = function() {
return $(this).hasClass("ui-draggable");
}
console.log($("#someElement").isDraggable());
#2
0
The dragstart
event is fired when dragging is started. More in the docs
当拖动启动时,将触发dragstart事件。更多的文档
#1
12
Maybe there's an easier way, but the docs say:
也许有更简单的方法,但是医生说:
Draggable elements gets a class of ui-draggable
Draggable元素获得一个ui-draggable类
so you could do something like:
你可以这样做:
if(!$("#foo").hasClass("ui-draggable")) {
...
}
so to wrap that up (untested):
总结一下(未经测试)
$.fn.isDraggable = function() {
return $(this).hasClass("ui-draggable");
}
console.log($("#someElement").isDraggable());
#2
0
The dragstart
event is fired when dragging is started. More in the docs
当拖动启动时,将触发dragstart事件。更多的文档