Is it possible to create a link_to_remote tag that will contruct the URL with Sortable.serialize for one of the URL parameters? I would like to serialize a list of ids and send them with an AJAX delete call so I can then re-order the list. For example, the final URL would include a parameter of ids like [1,2,3,4]: Thanks, Tom
I am using link_to_function and the javascript function would do the Ajax call, so I have all the freedom to serialize anything I need. function remote_call(form, controller,action,updatePanel ....){ .... new Ajax.Updater(updatePanel, ''/'' + controller + ''/'' + action + ''/'' + seller_id + ''?partial=true'', {asynchronous:true, evalScripts:true, onComplete:function(request){}, parameters:Form.serialize(form)}); } On 9/23/05, Tom Davies <atomgiant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Is it possible to create a link_to_remote tag that will contruct the > URL with Sortable.serialize for one of the URL parameters? > > I would like to serialize a list of ids and send them with an AJAX > delete call so I can then re-order the list. > > For example, the final URL would include a parameter of ids like > [1,2,3,4]: > > Thanks, > > Tom > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks Bogdan. That may be sufficient for my needs. Also, I noticed you are passing partial = true. If that is only so you know it is an AJAX request, there is a nice convenience method called xhr? on the request object that will be true if it is an XmlHttpRequest (I think it depends on the prototype library setting some headers). Tom On 9/24/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am using link_to_function and the javascript function would do the Ajax > call, so I have all the freedom to serialize anything I need. > > function remote_call(form, controller,action,updatePanel ....){ > .... > new Ajax.Updater(updatePanel, ''/'' + controller + ''/'' + action + ''/'' + > seller_id + ''?partial=true'', {asynchronous:true, evalScripts:true, > onComplete:function(request){}, parameters:Form.serialize(form)}); > } > > > On 9/23/05, Tom Davies <atomgiant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Is it possible to create a link_to_remote tag that will contruct the > > URL with Sortable.serialize for one of the URL parameters? > > > > I would like to serialize a list of ids and send them with an AJAX > > delete call so I can then re-order the list. > > > > For example, the final URL would include a parameter of ids like > [1,2,3,4]: > > > > Thanks, > > > > Tom > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >
Actually, after looking through the source for link_to remote I found that you can include extra parameters using the :with option. For example, to serialize an item called ''list'': :with => "Sortable.serialize(''list'')" Also, I''m not sure if this will help you Bogdan, but I noticed you are serializing a form and if you include a :form option, it will add the following to the remote url parameters: Form.serialize(this) It appears that you have to look in the code to see what options are available. The rdocs currently do not show some of these features. Tom On 9/24/05, Tom Davies <atomgiant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Bogdan. That may be sufficient for my needs. > > Also, I noticed you are passing partial = true. If that is only so > you know it is an AJAX request, there is a nice convenience method > called xhr? on the request object that will be true if it is an > XmlHttpRequest (I think it depends on the prototype library setting > some headers). > > Tom > > On 9/24/05, Bogdan Ionescu <bogdan.ionescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am using link_to_function and the javascript function would do the Ajax > > call, so I have all the freedom to serialize anything I need. > > > > function remote_call(form, controller,action,updatePanel ....){ > > .... > > new Ajax.Updater(updatePanel, ''/'' + controller + ''/'' + action + ''/'' + > > seller_id + ''?partial=true'', {asynchronous:true, evalScripts:true, > > onComplete:function(request){}, parameters:Form.serialize(form)}); > > } > > > > > > On 9/23/05, Tom Davies <atomgiant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Is it possible to create a link_to_remote tag that will contruct the > > > URL with Sortable.serialize for one of the URL parameters? > > > > > > I would like to serialize a list of ids and send them with an AJAX > > > delete call so I can then re-order the list. > > > > > > For example, the final URL would include a parameter of ids like > > [1,2,3,4]: > > > > > > Thanks, > > > > > > Tom > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > >