Everyone''s has to seen this but don''t know what it is called nor where to start. Take youtube for example, in their comments or tags section there is a (more) or (less) link that expands and collapses. Is this AJAX? How would you go about doing this is in Ruby? -- 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 -~----------~----~----~----~------~----~------~--~---
It''s JavaScript (probably) and there are various ways to do it - I''d recomend checking out the Prototype library which makes this kind of thing easer. Using Prototype you might do something like <div id=''thisPanel''>this is some text</div> <a href="#" onClick="$(''thisPanel'').show(); return false;">show</a> <a href="#" onClick="$(''thisPanel'').hide(); return false;">hide</a> Clicking the links will hide and show the ''thisPanel'' div. Expanding and contracting is similarly achieved but really depends on the type of effect you want. Dale On Apr 19, 7:55 pm, dlo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Everyone''s has to seen this but don''t know what it is called nor where > to start. Take youtube for example, in their comments or tags section > there is a (more) or (less) link that expands and collapses. Is this > AJAX? How would you go about doing this is in Ruby? > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
here''s another way that''s a bit more railsish: <div id="description"> <%= description.truncate(100) %> <%= link_to_function "(more)", f = update_page { |p| p.toggle("description"); p.toggle("description_more") } %> </div> <div id="description_more" style="display:none"> <%= description %> <%= link_to_function "(less)", f %> </div> This really isn''t AJAX. It would be, if the "more" description was being pulled from the server on click. On Apr 20, 1:20 pm, PeteSalty <petesa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It''s JavaScript (probably) and there are various ways to do it - I''d > recomend checking out the Prototype library which makes this kind of > thing easer. Using Prototype you might do something like > > <div id=''thisPanel''>this is some text</div> > <a href="#" onClick="$(''thisPanel'').show(); return false;">show</a> > <a href="#" onClick="$(''thisPanel'').hide(); return false;">hide</a> > > Clicking the links will hide and show the ''thisPanel'' div. Expanding > and contracting is similarly achieved but really depends on the type > of effect you want. > > Dale > > On Apr 19, 7:55 pm, dlo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > Everyone''s has to seen this but don''t know what it is called nor where > > to start. Take youtube for example, in their comments or tags section > > there is a (more) or (less) link that expands and collapses. Is this > > AJAX? How would you go about doing this is in Ruby? > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
So the function sits on the top of the view? I never really worked with Javascripts also. This is all new to me. Also, I was messing around, not sure, but I have multiple items from a search that I do. But I was limited to one item only to be able to toggle. I tried putting the entire item in a div, but couldn''t. Here is what I''m using: <script language="javascript"> function toggleDiv(divid){ if(document.getElementById(divid).style.display == ''none''){ document.getElementById(divid).style.display = ''block''; }else{ document.getElementById(divid).style.display = ''none''; } } </script> <td><a href="javascript:;" onmousedown="toggleDiv(''items<%=intCount%>'');">Show Items</a></td> <div id="items<%=intCount%>" style="display:none"> That is what I''m doing. I have to use intCount because I have multiple categories, and under each category are items. So, I want to display the category, but hide the items and use the more or less. Could you please elaborate if it is possible to do this? Eden Li wrote:> here''s another way that''s a bit more railsish: > > <div id="description"> > <%= description.truncate(100) %> > <%= link_to_function "(more)", f = update_page { |p| > p.toggle("description"); p.toggle("description_more") } %> > </div> > <div id="description_more" style="display:none"> > <%= description %> > <%= link_to_function "(less)", f %> > </div> > > This really isn''t AJAX. It would be, if the "more" description was > being pulled from the server on click.-- 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 -~----------~----~----~----~------~----~------~--~---