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?
jQueryUI provides draggable() method to make any DOM element draggable. Once the element is draggable, you can move that element by clicking on it with the mouse and dragging it anywhere within the viewport.
Syntax: $(selector, context). draggable ("action", [params]);
Check whether your draggable object is already loaded in the viewport. If it is not, it won't work properly. JUST AFTER the draggable object to be absolutely sure that everything is loaded at the correct time.
Using jQuery UI, we can make the DOM(Document Object Model) elements to drag anywhere within the view port. This can be done by clicking on the draggable object by mouse and dragging it anywhere within the view port. If the value of this option is set to false, it will prevent the DOM elements to be dragged .
Maybe there's an easier way, but the docs say:
Draggable elements gets a class of 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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With