Is there support yet for adding something to a list in sorted order? For example, you have a form to add a new item and you want the new item to be inserted in the list in the proper order. I''ve noticed the :position option in the form_remote_tag but it doesn''t seem like you can use it to keep things in sorted order. Rod Schmidt http://rodschmidt.blogspot.com "Do or do not. There is no try."
On 17/05/05, Rod Schmidt <rschmidt-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> wrote:> Is there support yet for adding something to a list in sorted order? > For example, you have a form to add a new item and you want the new > item to be inserted in the list in the proper order. I''ve noticed > the :position option in the form_remote_tag but it doesn''t seem like > you can use it to keep things in sorted order.Completely OT, but having ''insertion sort'' in the title gave me visions of undergrad comp sci... On topic though, I''m not sure it Rails lets you do that, but it''s fairly simple, just need an update at the right point to shuffle position''s around. -- Phillip Hutchings http://www.sitharus.com/ sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org
On 17.5.2005, at 03:03, Rod Schmidt wrote:> Is there support yet for adding something to a list in sorted order? > For example, you have a form to add a new item and you want the new > item to be inserted in the list in the proper order. I''ve noticed the > :position option in the form_remote_tag but it doesn''t seem like you > can use it to keep things in sorted order.Make the action where you send your form return the whole list of things, pre-sorted, like this: <div id="mystuff"> ...list of things... </div> <%= form_remote_tag :update => "mystuff", :url => { :action => "add_with_ajax" } %> Then make sure that add_with_ajax returns the whole "mystuff" list after it has added the new item. //jarkko> > Rod Schmidt > http://rodschmidt.blogspot.com > "Do or do not. There is no try." > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails