Hi, I am new to Ajax, and I was wondering if it is possible to have an id passed to a $() function in runtime. Like I am generating id for an article at runtime doing something like id=article-<%= article.id %> Now id I want to have a toggle element on this id then can I do Element.toggle(''$(''article-<%= article.id %>'')'', ''blind'') as well..??.. I cannot use the "this" parameter Thanks and regards Sanjay -- 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 8 Feb 2008, at 11:28, Sanjay Bisht wrote:> > Hi, > > I am new to Ajax, and I was wondering if it is possible to have an id > passed to a $() function in runtime. > > Like I am generating id for an article at runtime doing something like > id=article-<%= article.id %> > > Now id I want to have a toggle element on this id then can I do > Element.toggle(''$(''article-<%= article.id %>'')'', ''blind'') as > well..??.. > I cannot use the "this" parameter >If you mean runtime as in when the rjs is generated then yes: Element.toggle("$(''article-#{article.id }'')", ''blind'') If you mean runtime as in when the user''s browser executes the javascript then no. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Dosen''t seem to work like that also. Can you suggest some other work-around <p><%= link_to_function "Meta Information >>", "Element.toggle("$(''meta- #{article.id}'')", ''blind'')" %></p> Thanks and regards Frederick Cheung wrote:> On 8 Feb 2008, at 11:28, Sanjay Bisht wrote: > >> Element.toggle(''$(''article-<%= article.id %>'')'', ''blind'') as >> well..??.. >> I cannot use the "this" parameter >> > > If you mean runtime as in when the rjs is generated then yes: > Element.toggle("$(''article-#{article.id }'')", ''blind'') > If you mean runtime as in when the user''s browser executes the > javascript then no. > > 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 -~----------~----~----~----~------~----~------~--~---
Ok. thanks..it''s working fine..just some syntax issues..thanks a lot again Sanjay Bisht wrote:> Dosen''t seem to work like that also. Can you suggest some other > work-around > > <p><%= link_to_function "Meta Information >>", "Element.toggle("$(''meta- > #{article.id}'')", ''blind'')" %></p> > > Thanks and regards > > > > > > > Frederick Cheung wrote: >> On 8 Feb 2008, at 11:28, Sanjay Bisht wrote: >> >>> Element.toggle(''$(''article-<%= article.id %>'')'', ''blind'') as >>> well..??.. >>> I cannot use the "this" parameter >>> >> >> If you mean runtime as in when the rjs is generated then yes: >> Element.toggle("$(''article-#{article.id }'')", ''blind'') >> If you mean runtime as in when the user''s browser executes the >> javascript then no. >> >> 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 -~----------~----~----~----~------~----~------~--~---