On Thu, Jun 11, 2009 at 7:59 PM, Tyler Knappe<[email protected]> wrote:
> I have a function in my controller that loops over a div tag replacing > some text based up an updated variable set by the user. > > Code: > > ===== Controller ====== > > render :update do |page| > > for i in 0..23 do > for j in 0..6 do > if ([date calculation done here]) > page["test_div"].replace_html > "Checked Out" > else > page["test_div"].replace_html > "Available" > end > end > end > end > > ========== > > When the function is called, it only replaces a single element out of > the loop (the first). Is there a way to render all elements? It sounds > like RJS is the way to do this (http://www.ruby-forum.com/topic/135158) > but I still don't see how. It is not a good pratice to use render :update like that. When the RJS is more than a one-liner, say, it is more clean to extract that to its own RJS template. Because RJS belongs to the V in MVC. On the other hand the idea of the loop + calls to page...something is correct. In your example the ID of the element is always the same though. Knowing this, you could for example simplify the code like eliminating the conditional to get a wrong but working version, and after that add all the logic. --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

