Forum: Ruby on Rails RJS concurrency problems with lists

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.
B1112061b921903a0b337e10048798af?d=identicon&s=25 Chris (Guest)
on 2007-07-11 02:55
(Received via mailing list)

I'm using RJS to add and remove rows from a list of items. Ideally,
when the list is empty, there should be a single row "You have no
items", otherwise the list looks confusing with the header but no
items. Does anyone have a recipe for doing this?

Options include:

1. Update add and remove RJS templates to query the DB to get the item
count, and remove/add the special row as necessary. Has concurrency

2. When the page is initialized, put the display item count into the
session, and update add/remove actions to keep it up-to-date. Update
RJS templates as per option 1.

3. Implement a javascript function that takes the id of a list and
iterates over its children, inserting the "You have no items" row if

I'm leaning towards option 2, but if there is a cleaner approach that
would be awesome.

Dbbfa6d791e84b064c1ac1c04f49d9d0?d=identicon&s=25 unknown (Guest)
on 2007-07-11 04:54
(Received via mailing list)

The "you have no items" row could always be there. Just style it with
relative positioning such that it sits _under_ (z-index) the first
_real_ row of your list.

B1112061b921903a0b337e10048798af?d=identicon&s=25 Chris (Guest)
on 2007-07-11 09:01
(Received via mailing list)
Works perfectly. Thanks!

This topic is locked and can not be replied to.