Folks, 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 issues. 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 none. I''m leaning towards option 2, but if there is a cleaner approach that would be awesome. Cheers, Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
kennethkunz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-11 02:54 UTC
Re: RJS concurrency problems with lists
Chris, 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. Cheers, Ken On Jul 10, 7:54 pm, Chris <Chris.Hughes.Perso...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Folks, > > 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 > issues. > > 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 > none. > > I''m leaning towards option 2, but if there is a cleaner approach that > would be awesome. > > Cheers, > Chris--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Works perfectly. Thanks! Cheers, Chris On Jul 11, 12:54 pm, kennethk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Chris, > > 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. > > Cheers, > Ken--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---