Reputation: 4524
Does jQuery UI store any properties to a jQuery dom ref element?
What I'm particular interested in is any data or properties or function that can tell is it draggable?
Example:
var jqnode = jQuery('selector');
jqnode.draggable({...});
var isDraggable = !!(jqnode.tellIsDraggableProperty);
Upvotes: 0
Views: 83
Reputation: 140220
var isDraggable = !!jqnode.data("draggable")
or
var isDraggable = jqnode.is(":ui-draggable");
Depending on what you want to do, you could use the selector in the original:
jQuery('selector:ui-draggable').fn()
This would neatly only call fn
if it was draggable.
Upvotes: 3
Reputation: 219938
When jQueryUI initializes the draggable
, it add a ui-draggable
class to the element:
var isDraggable = jqnode.hasClass('ui-draggable');
Upvotes: 1
Reputation: 17013
I think this will do what you ask if I understand correctly.
var jqnode = jQuery('selector');
var isDraggable = (typeof jqnode.draggable === 'function');
Also, I think hasOwnProperty() would work too:
var jqnode = jQuery('selector');
var isDraggable = jqnode.hasOwnProperty('draggable');
Upvotes: 1