Sortable has a method similar to sequence named serialize. More
details are here:
http://wiki.script.aculo.us/scriptaculous/show/Sortable.serialize
but what you really want to know is that this is the format that post
expects. If you serialize both lists and give each its own proper key
you can then access this as a normal post.
When putting the two serialized strings together, remember to put an
ampersand (&) between them, otherwise they''ll merge and
you''ll be
missing some info :)
On Jul 18, 5:23 pm, Kim
<Kim.Gri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have two sortable lists that you can drag and drop to and from. Each
> object in the lists have a position field in the object''s table. I
> want to be able to update the position in the database automagically
> once a user has sorted the list.
>
> I can drag and drop just fine but I am not able to store the new
> positions in the database.
> I am trying to use Ajax.request in the onUpdate callback function. I
> am not sure how to pass the order of the lists as parameters so that
> the controller''s action can update the position. Below is the
related
> code.
>
> <script type="text/javascript"
language="javascript">
> // <![CDATA[
> Sortable.create("left",
>
{dropOnEmpty:true,containment:["left","right"],constraint:false,
> onUpdate:updateOrder});
>
> Sortable.create("right",
>
{dropOnEmpty:true,containment:["left","right"],constraint:false,
> onUpdate:updateOrder});
>
> function updateOrder(){
> var url = ''order'' //the action
> var left_list = escape(Sortable.sequence(''left''));
> var right_list = escape(Sortable.sequence(''right''));
> var left_ids = unescape(left_list).split('','');
> var right_ids = unescape(right_list).split('','');
> new Ajax.Request(url, {
> method: ''post'',
> parameters: left_ids // how do I pass both left
> and right ids and how do I use them in the action???
> });
> }
>
> // ]]>
>
> </script>
>
> def order
> //I need the new order so I can save it to the database
> end
>
> So, how do I pass the new order to the RoR action. Or is there a
> better approach then what I am doing?
>
> Please, please don''t answer with php examples or simple alert type
> examples.
>
> Thanks, K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---