Use jquery sortable but sort only specific class

368 Views Asked by At

I am using jQuery sortable function and it works. I'm also using thymeleaf.

My code looks something like this:

<div id="container">
        <div th:each = "drawer : &{drawers}" th:id="${drawer.id}">  
           <div class="sortableDrawer" th:include="drawer/drawer"></div>
        </div>
        <div class="mirror"></div>  
        </div>

Now I'm trying to sort every drawer in that div. I'm doing this and it works:

$('#container').sortable('toArray')

But this gives me an empty Array member which is the id of that tag with the class "mirror". I'm trying to get rid of this. Is it possible to somehow give a class, in this case "sortableDrawer" to the sortable function.

I want to do something like this:

$('#container').sortable(sortableDrawer, 'toArray')

Is there any way to do something like this or am I stuck with cleaning my Array from empty inputs?

1

There are 1 best solutions below

1
On

Are you searching for something like this?

 $('#container').sortable('toArray', { attribute: 'class' });