Basically I want to toggle the value of an element on a page via RJS. I can set the value fine, but I simply cannot figure out how to check the current value. This is essentially what I want to do: if page["element_id"].value == "0" page["element_id"].value = "1" else page["element_id"].value = "0" end The assignment lines (e.g. page["element_id"].value = "1") work fine. It''s that line to check the current value of the element that is killing me. Any experience with this? (Note: I have the RJS Templates for Rails PDF "book", but there is no mention of detecting or assigning values. And as usual, there isn''t much else out there on the ''Net.) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can do something like page << "if(blablabla){" page["element_id"].value = "1" page << "}else{" page["element_id"].value = "0" page << "}" Not pretty but gets the job done. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks. I was thinking about your suggestion, but I did not wish to go on a wild goose chase and I couldn''t find any confirmation for the idea out on the ''Net. Anyway, it looks like the above pretty much solves the problem. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---