CodeIgniter Forums
some jquery help needed (problem with sortable) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: some jquery help needed (problem with sortable) (/showthread.php?tid=14198)



some jquery help needed (problem with sortable) - El Forum - 12-22-2008

[eluser]Bramme[/eluser]
Hey all

I need some help with jQuery. Normally, I'd try and find out myself, but I've been trying all afternoon and can't figure it out.

I have a simple list that needs sorting. I'm using the jQuery UI sortable plugin.

This is what I have allready:
Code:
$(function() {
    $("#site_navigation a").click(function() {
        return false;
    });
    
    $("#site_navigation").sortable({
        items: "li",
        cursor: "move",
        update: function(event, el) {
            var foobar = $("#site_navigation").sortable("serialize");
            alert(foobar);
        }
    });
});
The update function is where I'm stuck: according to the docs, the serialize option should give me an array I can use to determine in which order the items are sorted. However, that alert turns up empty.

How do I proceed from here? Don't worry about the ajax, I'm pretty sure I can figure that out myself.


some jquery help needed (problem with sortable) - El Forum - 12-22-2008

[eluser]xwero[/eluser]
from the jquery ui docs :
Quote:It works by default by looking at the id of each item in the format 'setname_number', and it spits out a hash like "setname[]=number&setname;[]=number".



some jquery help needed (problem with sortable) - El Forum - 12-22-2008

[eluser]Bramme[/eluser]
god damn. i only had an id in format 'number'... added 'setname' and it works. thanks!