I''d like an interface similar to the del.icio.us one for tags, but I''m stuck when trying to add the tag name to an input field. What I''m trying to do is: page.select(''#tag_names'').each do |element| if element.value.to_s.empty? element.value = @tag.name else element.value = element.value.to_s + ", #{@tag.name}" end end but it doesn''t work ... Suggestions ? TIA, ngw --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I would test whether element.value gives you access to the DOM element in the way you expect. Here''s a quote from Cody Fauser''s RJS Templates for Rails that may have some bearing on what you''re trying to do: "When using a direct element proxy rather than a string passed to <<, the generator assumes that the proxied call is a method call and automatically adds (). This means that you can''t directly proxy an element''s property, such as element.innerHTML. page.select(''#elements span'').any(''allVisible'') do |value, index| page << ''!value.visible()'' end" Dave On Mar 12, 4:45 pm, Nicholas Wieland <nicholas.wiel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''d like an interface similar to the del.icio.us one for tags, but > I''m stuck when trying to add the tag name to an input field. > What I''m trying to do is: > > page.select(''#tag_names'').each do |element| > if element.value.to_s.empty? > element.value = @tag.name > else > element.value = element.value.to_s + ", #...@tag.name}" > end > end > > but it doesn''t work ... > Suggestions ? > > TIA, > ngw--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Il giorno 13/mar/07, alle ore 01:52, Dave ha scritto:> > I would test whether element.value gives you access to the DOM element > in the way you expect. > > Here''s a quote from Cody Fauser''s RJS Templates for Rails that may > have some bearing on what you''re trying to do:Very close, thanks ... It seems to me that I can''t fetch or use what''s inside the value attribute of the input field, it doesn''t return a string but a JavascriptElementProxy that doesn''t have a to_str/to_s method. I need to check if that value is empty, and if not I need to use it for the new value ... I will never be able to get out from this alone :p TIA, ngw --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Very close, thanks ... > It seems to me that I can''t fetch or use what''s inside thevalue > attribute of the input field, it doesn''t return a string but a JavascriptElementProxythat doesn''t have a to_str/to_smethod. > I need to check if thatvalueis empty, and if not I need to use it > for the newvalue... > I will never be able to get out from this alone :pAny luck on getting the value? I am running into the same issue. Thanks, Greg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Was this issue ever resolved? if so I would love to know how!! Jason. gblasko wrote:>> Very close, thanks ... >> It seems to me that I can''t fetch or use what''s inside thevalue >> attribute of the input field, it doesn''t return a string but a JavascriptElementProxythat doesn''t have a to_str/to_smethod. >> I need to check if thatvalueis empty, and if not I need to use it >> for the newvalue... >> I will never be able to get out from this alone :p > > Any luck on getting the value? I am running into the same issue. > > Thanks, > Greg-- 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 -~----------~----~----~----~------~----~------~--~---
On Oct 4, 6:27 am, Jason Franklin-stokes <rails-mailing-l...@andreas- s.net> wrote:> Was this issue ever resolved? if so I would love to know how!! > Jason. >At the time the RJS runs you cannot find the value of an element: the rjs is running on the server, but the info is on the client''s page. So for example, if page[:something].empty? ... or anything like that is impossible. You can however generate javascript that will check a certain condition, for example page << "if($F(''foo'') == ''bar''){" page[:baz].hide() page << "}" I waffled about this at some length here: http://www.spacevatican.org/2008/5/26/conditional-rjs-explained Fred> gblasko wrote: > >> Very close, thanks ... > >> It seems to me that I can''t fetch or use what''s inside thevalue > >> attribute of the input field, it doesn''t return a string but a JavascriptElementProxythat doesn''t have a to_str/to_smethod. > >> I need to check if thatvalueis empty, and if not I need to use it > >> for the newvalue... > >> I will never be able to get out from this alone :p > > > Any luck on getting the value? I am running into the same issue. > > > Thanks, > > Greg > > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, for the quick reply - I actually read your article earlier on thanks. Hmm, now lets see if I am getting this right. When I write somthing in the RJS file the page object takes my DLD and transforms it into javascript which is immediatley sent out to the browser which then does the rendering it has been asked for. I hope I got that bit right? As it is possible to send snippits of javascript to the browser and ask it to get me a value of a DOM back, then I ask by self why this request cannot be handled by the javascript engine in rails. The only logical explination to me is that asking the browser and telling the browser are 2 completely different things. So that would mean that the rails javascript engine has been written to handle all the "tell stuff" - but it can''t handle the "ask stuff" i.e. that engine is probably missing. Could it be that the underlying problem is that the messaging (responder, initiator sequence) is entirely differnt depending on what is being done (asking or telling). If all this is understandable and the answer is (yes this is how it works) then I will be relieved to know. Thanks a million Jason Frederick Cheung wrote:> On Oct 4, 6:27�am, Jason Franklin-stokes <rails-mailing-l...@andreas- > s.net> wrote: >> Was this issue ever resolved? if so I would love to know how!! >> Jason. >> > > At the time the RJS runs you cannot find the value of an element: the > rjs is running on the server, but the info is on the client''s page. > So for example, > if page[:something].empty? > ... > > or anything like that is impossible. > You can however generate javascript that will check a certain > condition, for example > page << "if($F(''foo'') == ''bar''){" > page[:baz].hide() > page << "}" > > I waffled about this at some length here: > http://www.spacevatican.org/2008/5/26/conditional-rjs-explained > > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 4, 12:19 pm, Jason Franklin-stokes <rails-mailing-l...@andreas- s.net> wrote:> Thanks, for the quick reply - > I actually read your article earlier on thanks. > > Hmm, now lets see if I am getting this right. > When I write somthing in the RJS file the page object takes my DLD and > transforms it into javascript which is immediatley sent out to the > browser which then does the rendering it has been asked for. > > I hope I got that bit right? >Yup.> As it is possible to send snippits of javascript to the browser and ask > it to get me a value of a DOM back, then I ask by self why this request > cannot be handled by the javascript engine in rails. > > The only logical explination to me is that asking the browser and > telling the browser are 2 completely different things. > > So that would mean that the rails javascript engine has been written to > handle all the "tell stuff" - but it can''t handle the "ask stuff" i.e. > that engine is probably missing. > > Could it be that the underlying problem is that the messaging > (responder, initiator sequence) is entirely differnt depending on what > is being done (asking or telling). >I think you''re overcomplicating things. Rails generates javascript for you. It doesn''t evaluate it. It has neither a javascript engine, nor access to all the state of the browser. There isn''t any messaging either, just code generation. There''s some clever stuff going on with RJS, but that''s mostly to make things flow nicely, so that you can write page[:foo].hide or page[:foo].show rather than something like hideElement(''foo'') or callElementFunction(''foo'', ''hide'') The trick here is that page[:foo] is not the dom element with id foo. It''s a magic proxy object that knows that when you call hide on it it should generate $(''foo'').hide You could send the javascript back, have the browser evaluate it and post back a result, but obviously incurs a server round-trip and would be completely inappropriate for this (not to mention the fact that that request would be handled by another mongrel etc...) Fred> If all this is understandable and the answer is (yes this is how it > works) then I will be relieved to know. > > Thanks a million > Jason > > > > Frederick Cheung wrote: > > On Oct 4, 6:27 am, Jason Franklin-stokes <rails-mailing-l...@andreas- > > s.net> wrote: > >> Was this issue ever resolved? if so I would love to know how!! > >> Jason. > > > At the time the RJS runs you cannot find the value of an element: the > > rjs is running on the server, but the info is on the client''s page. > > So for example, > > if page[:something].empty? > > ... > > > or anything like that is impossible. > > You can however generate javascript that will check a certain > > condition, for example > > page << "if($F(''foo'') == ''bar''){" > > page[:baz].hide() > > page << "}" > > > I waffled about this at some length here: > >http://www.spacevatican.org/2008/5/26/conditional-rjs-explained > > > Fred > > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi everybody! I have a problem with rjs. After submit the form, rjs not run. I would like clear a text_field_tag. Here is my code: --ActionController-- def add_post @post = ChatPost.new(:ctext => params[:message]) @post.chat_room_id = session[''selectedroomid''] @post.lang = session[:locale] @post.save end --View-- <% form_remote_tag :url => {:action => ''add_post''} do %> <%= text_field_tag "message", "", :size => 75%> <%= submit_tag "Küldés" %> <% end %> --rjs - called: add_post.rjs-- page[''message''].value = '''' I includ this:<%= javascript_include_tag :defaults %> in template. I see in firebug that, the request is called and http status is 200, but the field don''t clear. Please help me. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Asd Asd wrote:> I have a problem with rjs. After submit the form, rjs not run. I would > like clear a text_field_tag. Here is my code:Your code looks OK at first glance. Check to make sure you don''t have another DOM element on the page with an id/name of ''message''. HTH, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> Hi, > > Asd Asd wrote: > >> I have a problem with rjs. After submit the form, rjs not run. I would >> like clear a text_field_tag. Here is my code: > > Your code looks OK at first glance. Check to make sure you don''t have > another DOM element on the page with an id/name of ''message''. > > HTH, > BillI haven''t other Dom element in page with an id/name of ''message''. It''s incredible. darkhck -- 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 -~----------~----~----~----~------~----~------~--~---