AnthW
AnthW

Reputation: 543

Jquery UI Sortable - Child element moves parent items

I have the following html:

<div class="wrapper">
    <div class="box">
        <div class="box__title">
            <div class="box__move">move</div>
        </div>
        <div class="box__description">
        </div>
    </div>
    <div class="box">
        <div class="box__title">
            <div class="box__move">move</div>
        </div>
        <div class="box__description">
        </div>
    </div>
</div>

I would like "box__move" to be the trigger to move "box" items within the "wrapper".

I was hoping something like the following might work, but hasn't. So, wondering if there is actually a way to do this.

$('.box__move').sortable({
    axis: 'y',
    items: 'parent .box'
});

Anyone able to assist, or is this not possible?

Upvotes: 1

Views: 2588

Answers (2)

kamilkp
kamilkp

Reputation: 9800

Try:

$('.wrapper').sortable({
    axis: 'y',
    handle: '.box__move'
});

Upvotes: 2

brunozrk
brunozrk

Reputation: 783

$('.wrapper').sortable({
    axis: 'y',
    handle: '.box__move'
});

Upvotes: 0

Related Questions