ICE
ICE

Reputation: 31

how to apply jquery ui draggable more than one time to same element

How can I apply jquery ui draggable or resizable more than one time to same element? For example:

<div style="height: 50px; left: 216px; position: absolute; top: 64px; width: 444px; z-index: 1; class="test-12 ui-resizable ui-draggable" id="div-77">
   <div class="ui-resizable-handle ui-resizable-e" style="z-index: 1000;"></div>
   <div class="ui-resizable-handle ui-resizable-s" style="z-index: 1000;"></div>
   <div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 1000;"></div>
   <div class="ui-rotatable-handle ui-draggable show"></div> 
</div>

I want to apply jquery draggable and resizable to this div (id=div-77) with these other divs

thank you

Upvotes: 0

Views: 775

Answers (1)

TJ VanToll
TJ VanToll

Reputation: 12704

Like most things in jQuery you can use a CSS selector to choose the elements you want. This will make all divs resizable and draggable.

$('div')
    .resizable()
    .draggable();

If you just want the div with ```id="div-77" you can use.

$('#div-77')
    .draggable()
    .resizable();

Calling draggable or resizable on the same element multiple times has no ill effect. jQuery UI internally is smart enough to know that it has already made the element draggable or resizable accordingly.

Upvotes: 1

Related Questions