Max_Salah
Max_Salah

Reputation: 2497

how to get the order of certain items with jquery sortable("toArray")

In this example: http://jsfiddle.net/ga89T/10/

I have 3 Sections (section 1, section 3 and section 3). In this example you can try, when I sort the sections, the function sortable("toArray") returns the order of those sections.

Now I would like to get the order of such sections with class="current".

I tried the following:

$("#accordion.current").sortable("toArray"); 

but it returns [object object]

How can I select certain sections to be sorted?

Upvotes: 0

Views: 547

Answers (1)

pimvdb
pimvdb

Reputation: 154818

First, you should use the descendant operator because the sortable itself doesn't have a .current class. Second, you may be better off using the .map function: http://jsfiddle.net/ga89T/12/.

var order = $("#accordion .current").map(function() {
    return this.id;
}).get();

Upvotes: 1

Related Questions