Skip to main content

Search and Top Navigation

#4043 closed bug (notabug)

Opened February 02, 2009 07:10PM UTC

Closed February 06, 2009 02:41AM UTC

sortable("serialize", {attribute: "anything"}) returns no value

Reported by: ajacksified Owned by:
Priority: critical Milestone: 1.7
Component: ui.sortable Version: 1.6rc6
Keywords: sortable, serialize, toArray Cc:
Blocked by: Blocking:
Description

The "serialize" argument does not work when specifying an attribute; nothing is returned. The same code with "toArray" returns the expected result.

<ul id="sortableList" class="sortableList">
    <li id="Li1" itemid='1'>
         ...
    </li>
    <li id="Li2" itemid='2'>
         ...
    </li>
    <li id="Li3" itemid='3'>
         ...
    </li>
</ul>

<script type="text/javascript">
$(".sortableList").sortable({
    scroll: true,
    axis: "y", 
    containment: "parent",
    handle: $("div.sortableListTitleText").add("div.handle.move"),
    update: function(){
        var newList = $(".sortableList").sortable( "serialize", {attribute: "itemid"});
    }
});
</script>

newList is empty; however, using var newList = $(".sortableList").sortable( "toArray", {attribute: "itemid"}); returns an array of 'itemid' values.

Attachments (0)
Change History (4)

Changed February 02, 2009 07:14PM UTC by rdworth comment:1

priority: majorcritical

Changed February 06, 2009 02:41AM UTC by paul comment:2

resolution: → fixed
status: newclosed

That's not a bug. the value must be something like 'name_1' or 'name-1' in order to match the default expression that will then construct a query string like name[]=1&name[]=2. What you probably want is to use the 'key' option and set it to 'itemid' as well:

sortable('serialize', {

attribute: 'itemid',

key: 'itemid'

})

This should do the job for you.

Changed February 06, 2009 02:41AM UTC by paul comment:3

resolution: fixed
status: closedreopened

Changed February 06, 2009 02:41AM UTC by paul comment:4

resolution: → invalid
status: reopenedclosed