开发者

How do I keep child elements together with parent jQuery sortable

开发者 https://www.devze.com 2022-12-26 05:35 出处:网络
I have a list of items like this... <ol> <li> <span></span> <img src="image.png" />

I have a list of items like this...

<ol>
    <li>
        <span></span>
        <img src="image.png" />
        <p>Image Caption</p>
    </li>
</ol>

And I want to be able to sort the LI's but not the sub elements, they should just move with their parent.

I am using the jQuery to do that...

$('ol li').sortable({ 'cursor': 'move' });

And its working but not moving the whole lot just the element you clicked i.e. the <p>, <img> or <span>

I can't figure out how to solve this so I looked about and found an option called 'items': '> li' which was recommended but upon using this nothing drags any more but using firebug + jquery plugin I can see there is a sortable on the <li> still.

Not sure what to do, example here: http://clareshilland.unknowndomain.co.uk/

  1. Press ctrl+l to login.

  2. Enter the login details:

    Username: clare

    Password: demo

  3. Selec开发者_运维技巧t 'edit' from under then 'image' portion of the menu.

  4. The sortables should be those polaroids.

Thanks in advance, another one I've been banging my head on the table with.


$('ol').sortable({ 'cursor': 'move' });

sortable() applies to the container and affects the children. Your 'ol li' selector makes the li the container, which results in the behavior your see.

0

精彩评论

暂无评论...
验证码 换一张
取 消