Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery UI Sortable - restrict drag area of an html sortable element to a specific child element

This is my simplified div structure on which i applied the JQuery UI sortable interaction (see this JS Fiddle example):

<div id="sortable_panels">
    <div class="panel" id="panel1">
        <div class="header" id="panel1_header">Panel 1 header</div>
        <div id="panel1_content"></div>                    
    </div>    
    <div class="panel" id="panel2">
        <div class="header" id="panel2_header">Panel 2 header</div>
        <div id="panel2_content"></div>                    
    </div>    
    <div class="panel" id="panel3">
        <div class="header" id="panel3_header">Panel 3 header</div>
        <div id="panel3_content"></div>                    
    </div>    
    <div class="clear"></div>
</div>​

I want a panel to be draggable only when I drag the panel headers. Is there a way to accomplish this?

like image 758
Daniel Buhai Avatar asked Dec 12 '12 15:12

Daniel Buhai


People also ask

How to use jQueryUI sortable?

Enable a group of DOM elements to be sortable. Click on and drag an element to a new spot within the list, and the other items will adjust to fit. By default, sortable items share draggable properties.

How does jquery sortable work?

jQueryUI provides sortable() method to reorder elements in list or grid using the mouse. This method performs sortability action based upon an operation string passed as the first parameter.

How do I turn off sortable?

You can use . sortable("enable") and . sortable("disable") to toggle the sortable widget on and off.


1 Answers

you can use this option in your sortable interaction

handle:'.header'
like image 67
Karthi Keyan Avatar answered Oct 02 '22 17:10

Karthi Keyan