Davo
2007-May-27 09:48 UTC
making a list of records refresh in order after a ''page.insert_html''
Hi Everyone, I''m working through a book that demonstrates using Ajax to add a new record to a category. Just a single field, being a name is required. I''ve applied it to a real app and it works OK except for one small detail. The add facility is on the same page as the list of existing categories, & I made one change which is to display the existing entries in name order. But when a new one is added it adds to the bottom ( which is what it is told to do ), but I want the list to be refreshed with the new item in it''s alphabetical position. The only options for page.insert_html are: top, bottom, before and after. Here is the ''new'' def: def new @make = Make.new(params[:make]) if @make.save return if request.xhr? render :partial => ''make'', :object => @make end end Here is the rjs code: if @make.new_record? page.alert @make.errors.full_messages.join("\n") else page.insert_html :bottom, ''make_list'', :partial => ''make'' page.visual_effect :highlight, "make_#{@make.id}" page.form.reset ''make_form'' end ( note: The book is using a ''category'' table where my app is using a ''make'' table ) Anyone know how to accomplish this ? TIA - Dave Porter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Zach Inglis // LT3media
2007-May-27 11:14 UTC
Re: making a list of records refresh in order after a ''page.insert_html''
You could assign each row (whether it be li, or dd, or tr) with their ID, and then in your ruby code find out where it should be, and insert below that. The only thing I can think of in these wee hours. Cheers, Zach Inglis → Blog -- http://www.zachinglis.com → Company -- http://www.lt3media.com → Portfolio -- http://portfolio.zachinglis.com On May 27, 2007, at 4:48 AM, Davo wrote:> > Hi Everyone, > > I''m working through a book that demonstrates using Ajax to add a new > record to a category. Just a single field, being a name is required. > > I''ve applied it to a real app and it works OK except for one small > detail. > > The add facility is on the same page as the list of existing > categories, & I made one change which is to display the existing > entries in name order. But when a new one is added it adds to the > bottom ( which is what it is told to do ), but I want the list to be > refreshed with the new item in it''s alphabetical position. > > The only options for page.insert_html are: top, bottom, before and > after. > > Here is the ''new'' def: > > def new > @make = Make.new(params[:make]) > if @make.save > return if request.xhr? > render :partial => ''make'', :object => @make > end > end > > Here is the rjs code: > > if @make.new_record? > page.alert @make.errors.full_messages.join("\n") > else > page.insert_html :bottom, ''make_list'', :partial => ''make'' > page.visual_effect :highlight, "make_#{@make.id}" > page.form.reset ''make_form'' > end > > ( note: The book is using a ''category'' table where my app is using a > ''make'' table ) > > Anyone know how to accomplish this ? > > TIA - Dave Porter > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
alexander-0M91wEDH++c@public.gmane.org
2007-May-27 11:15 UTC
Re: making a list of records refresh in order after a ''page.insert_html''
dear sender, i´m out of the office until may 29th. your email will not be forwarded. for urgent stuff please contact joern-0M91wEDH++c@public.gmane.org kind regards, alexander --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Davo
2007-May-27 11:40 UTC
Re: making a list of records refresh in order after a ''page.insert_html''
Thanks Zach, Sounds a bit complicated for a newbie ! Not life threatening so I''ll come back to it. regards, Dave On May 27, 7:14 pm, Zach Inglis // LT3media <l...-w8tEHcFK2X5Wk0Htik3J/w@public.gmane.org> wrote:> You could assign each row (whether it be li, or dd, or tr) with their > ID, and then in your ruby code find out where it should be, and > insert below that. The only thing I can think of in these wee hours. > > Cheers, > Zach Inglis > → Blog --http://www.zachinglis.com > → Company --http://www.lt3media.com > → Portfolio --http://portfolio.zachinglis.com > > On May 27, 2007, at 4:48 AM, Davo wrote: > > > > > Hi Everyone, > > > I''m working through a book that demonstrates using Ajax to add a new > > record to a category. Just a single field, being a name is required. > > > I''ve applied it to a real app and it works OK except for one small > > detail. > > > The add facility is on the same page as the list of existing > > categories, & I made one change which is to display the existing > > entries in name order. But when a new one is added it adds to the > > bottom ( which is what it is told to do ), but I want the list to be > > refreshed with the new item in it''s alphabetical position. > > > The only options for page.insert_html are: top, bottom, before and > > after. > > > Here is the ''new'' def: > > > def new > > @make = Make.new(params[:make]) > > if @make.save > > return if request.xhr? > > render :partial => ''make'', :object => @make > > end > > end > > > Here is the rjs code: > > > if @make.new_record? > > page.alert @make.errors.full_messages.join("\n") > > else > > page.insert_html :bottom, ''make_list'', :partial => ''make'' > > page.visual_effect :highlight, "make...-UGChcxq6l7c@public.gmane.org}" > > page.form.reset ''make_form'' > > end > > > ( note: The book is using a ''category'' table where my app is using a > > ''make'' table ) > > > Anyone know how to accomplish this ? > > > TIA - Dave Porter--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---