0 0 Votes

jQuery UI Draggable: Multiple Cancel-Selectors

Question by Compi | 11/06/2014 at 16:18

I am using the jQuery UI widget "Draggable" to be able to move a DIV-Box on my website. However, on some elements placed on the DIV, the movement should not be possible (for example on input fields).

Up to now, I have the following code which is really working very very good (cancel contains the elements, on which it should not be possible to start the move).

$(".movebox").draggable({
   cursor: 'move',
   cancel: '.nodrag'
});

However, this is only a working, when only providing one selector in "cancel". I would like to add input fields as well as textareas here, too.

Is it possible to use "cancel" with multiple selectors?

ReplyPositiveNegative

Stefan Trost

Show Profile | Message
Avatar
0Best Answer
0 Votes

You can just separate multiple selectors using a comma:

cancel: '.nodrag, #myid, textarea, input' 

This selector would select all elements having assigned the class "nodrag", the element with the ID "myid" as well as all textareas and input elements.

More information about this, you can find on the jQuery website on to the topic Multiple Selector.
11/06/2014 at 18:43

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.