Nick Coyne
2006-Apr-26 13:45 UTC
[Rails] Newbie: Hide div I''ve just show using link_to_remote?
I''m using link_to_remote to show details for an item that''s clicked. I''d like to hide the div with the next click, or alternatively have a "Hide" link within my div. What is the best way to accomplish this? Here''s my existing code: <% for task in @mytasks %> <div class="rowFormat"> <%= link_to_remote( "#{task.title}", :update => "task_#{task.id}", :url =>{:controller => ''front/tasks'', :action => ''show'', :id => task} )%> </div> <div id="task_<%=task.id%>"></div> <% end %> -- Posted via http://www.ruby-forum.com/.
Mike Garey
2006-Apr-26 14:46 UTC
[Rails] Newbie: Hide div I''ve just show using link_to_remote?
why not use Element.toggle? <%= link_to_remote("Toggle List", :after => "Element.toggle(''list'')") %> the above will display the element with id ''list'' if it''s hidden, and hide it if it''s shown. Mike On 4/26/06, Nick Coyne <nic@nickcoyne.com> wrote:> > I''m using link_to_remote to show details for an item that''s clicked. I''d > like to hide the div with the next click, or alternatively have a "Hide" > link within my div. > > What is the best way to accomplish this? > > Here''s my existing code: > > <% for task in @mytasks %> > <div class="rowFormat"> > <%= link_to_remote( "#{task.title}", > :update => "task_#{task.id}", > :url =>{:controller => ''front/tasks'', :action => > ''show'', :id => task} )%> > </div> > <div id="task_<%=task.id%>"></div> > <% end %> > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060426/98b7b320/attachment.html
Alan Francis
2006-Apr-26 15:03 UTC
[Rails] Re: Newbie: Hide div I''ve just show using link_to_remote?
Just to add to Mike''s post, I''d look at the standard rails index.html as it does that very thing with the about DIV. A. -- Posted via http://www.ruby-forum.com/.
Nick Coyne
2006-Apr-26 15:08 UTC
[Rails] Re: Newbie: Hide div I''ve just show using link_to_remote?
Mike Garey wrote:> why not use Element.toggle? > > <%= link_to_remote("Toggle List", :after => "Element.toggle(''list'')") %> > > the above will display the element with id ''list'' if it''s hidden, and > hide > it if it''s shown. > > MikeThat works great, except it only starts toggling after the 2nd click on the link. The first click does nothing. My code now looks like this; <%= link_to_remote( "#{task.title}", :url =>{:controller => ''front/tasks'', :action => ''show'', :id => task}, :update => "task_#{task.id}", :after => "Element.toggle(''task_#{task.id}'')" )%> Thanks! -- Posted via http://www.ruby-forum.com/.
Nick Coyne
2006-Apr-26 15:15 UTC
[Rails] Re: Newbie: Hide div I''ve just show using link_to_remote?
Alan Francis wrote:> Just to add to Mike''s post, I''d look at the standard rails index.html as > it does that very thing with the about DIV. > > A.That''s exactly what I want to do, but unfortunately the standard index.html doesn''t use rails to achieve its effect, it uses scriptaculous directly in a std html file. -- Posted via http://www.ruby-forum.com/.
Mike Garey
2006-Apr-26 15:33 UTC
[Rails] Re: Newbie: Hide div I''ve just show using link_to_remote?
On 4/26/06, Nick Coyne <nic@nickcoyne.com> wrote:> > Alan Francis wrote: > > Just to add to Mike''s post, I''d look at the standard rails index.html as > > it does that very thing with the about DIV. > > > > A. > > That''s exactly what I want to do, but unfortunately the standard > index.html doesn''t use rails to achieve its effect, it uses > scriptaculous directly in a std html file.maybe try setting the display css attribute of the div to inline, ie: <div ''list'' style="display:inline"> my list </div> <%= link_to_remote("Toggle List", :after => "Element.toggle(''list'')") %> since Element.toggle simply changes the display attribute from ''inline'' to ''none'', so it may have a problem if you don''t initially set any display attribute. Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060426/7c6d8872/attachment.html
Nick Coyne
2006-Apr-26 15:45 UTC
[Rails] Re: Newbie: Hide div I''ve just show using link_to_remote
Ok, got it to do what I want, the default index.html helped a bit. My link now looks like: <%= link_to_remote( "#{task.title}", :url =>{:controller => ''front/tasks'', :action => ''show'', :id => task}, :update => "task_#{task.id}", :complete => visual_effect(:BlindDown, "task_#{task.id}", :duration => 1))%> Couldn''t figure out how to do the blind effect with the toggle. Then my empty div looks like: <divstyle="display: none" id="task_<%=task.id%>"></div> And my page that provides the content has a "Hide" link that looks like: <a onClick="new Effect.BlindUp(''task_<%=@task.id%>'',{duration:0.5})">Hide</a> Works great! Thanks Mike and Alan! Mike Garey wrote:> On 4/26/06, Nick Coyne <nic@nickcoyne.com> wrote: >> >> Alan Francis wrote: >> > Just to add to Mike''s post, I''d look at the standard rails index.html as >> > it does that very thing with the about DIV. >> > >> > A. >> >> That''s exactly what I want to do, but unfortunately the standard >> index.html doesn''t use rails to achieve its effect, it uses >> scriptaculous directly in a std html file. > > > > maybe try setting the display css attribute of the div to inline, ie: > > <div ''list'' style="display:inline"> > my list > </div> > > <%= link_to_remote("Toggle List", :after => "Element.toggle(''list'')") %> > > since Element.toggle simply changes the display attribute from ''inline'' > to > ''none'', so it may have a problem if you don''t initially set any display > attribute. > > Mike-- Posted via http://www.ruby-forum.com/.
Kfir Lavi
2006-Apr-26 16:09 UTC
[Rails] Re: Newbie: Hide div I''ve just show using link_to_remote?
I have the same problem showing div item that its initial state is set to ''none''. It seems that when the initial state is ''none'', Element.toggle can''t change it to ''inline''. what i did to solve the problem, is using the ''onload'' event. I''m starting by showing the div and then when the page loads, it uses ''onload'' to switch to ''none'', then the toggling works. Is there a way not to use this hack? tnx Kfir
mixplate
2006-Dec-07 14:44 UTC
Re: Re: Newbie: Hide div I''ve just show using link_to_remote
im working on this problem also. actually i sort of stuck where i load a javascript behavior on :loading. i dont have the code in front of me, but its something like newEffect.Highlight(''somediv''#{obj.id}) the updating of the div works but doesnt load the effect. 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 -~----------~----~----~----~------~----~------~--~---