Forum: Ruby on Rails making a list of records refresh in order after a 'page.inse

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4b0889adddec0b9bae5435e0c233b1e3?d=identicon&s=25 Davo (Guest)
on 2007-05-27 11:49
(Received via mailing list)
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

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

Here is the 'new' def:

  def new
    @make =[:make])
      return if request.xhr?
      render :partial => 'make', :object => @make

Here is the rjs code:

if @make.new_record?
  page.alert @make.errors.full_messages.join("\n")
  page.insert_html :bottom, 'make_list', :partial => 'make'
  page.visual_effect :highlight, "make_#{}"
  page.form.reset 'make_form'

( 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
Df4978da52459529e539da4c995918cb?d=identicon&s=25 Zach Inglis // LT3media (Guest)
on 2007-05-27 13:15
(Received via mailing list)
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.

Zach Inglis
→ Blog --
→ Company --
→ Portfolio --
4b0889adddec0b9bae5435e0c233b1e3?d=identicon&s=25 Davo (Guest)
on 2007-05-27 13:42
(Received via mailing list)
Thanks Zach,

Sounds a bit complicated for a newbie !  Not life threatening so I'll
come back to it.

regards, Dave
7a03066e8719f4d938bf622351ce4e7b?d=identicon&s=25 unknown (Guest)
on 2007-09-25 23:02
(Received via mailing list)
dear sender,
i´m out of the office until may 29th.
your email will not be forwarded.
for urgent stuff please contact
kind regards,
This topic is locked and can not be replied to.