Hey there I''m trying to test this condition in an RJS template if page[''search''].value == "somequerystring" And it never returns true. Any ideas? I''ve used page[''element''] = value for setting a textbox in the past with no problem. Not sure what checking the value would fail. Thanks. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Guest wrote:> Hey there I''m trying to test this condition in an RJS template > > if page[''search''].value == "somequerystring" > > And it never returns true. Any ideas? > > I''ve used page[''element''] = value for setting a textbox in the past with > no problem. Not sure what checking the value would fail. > > Thanks. > > -- > Posted via http://www.ruby-forum.com/.RJS templates are a bit misleading. They are produced server side and don''t have access to the state of the client side. So you can''t test on the value of something on the page in the RJS template itself. You can render a JS conditional, or you can pass the value you are interested in as a parameter to the call that invokes the RJS action. _Kevin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
_Kevin, That makes good sense. If anyone else runs into this, here''s the syntax page << "if($(''search'').value == ''#{session[:value]}'') {" # do stuff here page << "}" Thanks _Kevin. _Kevin wrote:> Guest wrote: >> >> -- >> Posted via http://www.ruby-forum.com/. > > RJS templates are a bit misleading. They are produced server side and > don''t have access to the state of the client side. So you can''t test > on the value of something on the page in the RJS template itself. > > You can render a JS conditional, or you can pass the value you are > interested in as a parameter to the call that invokes the RJS action. > > _Kevin-- 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?hl=en -~----------~----~----~----~------~----~------~--~---
You might be interested in http://www.agilewebdevelopment.com/plugins/rjs_if_unless_blocks I don''t know if it does exactly what you''re interested in, but it''s pretty good in other cases for getting rid of that fairly ugly syntax 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?hl=en -~----------~----~----~----~------~----~------~--~---