tags:

views:

82

answers:

1

Hello, I just saw this cool feature of JQuery which is JQuery Portlet

http://jqueryui.com/demos/sortable/portlets.html

I was just wondering how do i persist this to my database? so that it's available even for future sessions to all users of my website?

+1  A: 

jQuery's Portlet widget has a serialize method that would do just that. Read how to use it here: http://jqueryui.com/demos/sortable/#method-serialize

Serializes the sortable's item id's into a form/ajax submittable string. Calling this method produces a hash that can be appended to any url to easily submit a new item order back to the server.

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".

You can also give in a option hash as second argument to custom define how the function works. The possible options are: 'key' (replaces part1[] with whatever you want), 'attribute' (test another attribute than 'id') and 'expression' (use your own regexp).

If serialize returns an empty string, make sure the id attributes include an underscore. They must be in the form: "set_number" For example, a 3 element list with id attributes foo_1, foo_5, foo_2 will serialize to foo[]=1&foo[]=5&foo[]=2. You can use an underscore, equal sign or hyphen to separate the set and number. For example foo=1 or foo-1 or foo_1 all serialize to foo[]=1.

aefxx