i was thinking, that for alot of my application, when i have a record, i want a menu with all the related ajax calls linked to a that record. there might me a gem to do this, or an easier way, but this is what i did. i am open to new ideas, as this was made to work easily from any view by calling a partial and setting up the ajax info in the helpers. what do you all think about this type of DRY? is there another better way? i got it working on link_to but now working on link_to_remote. views>layout>_menu.rhtml <!-- suckerfish css, VERY simple, to work in all browsers, i hope. --> <%= stylesheet_link_tag ''ajaxmenu'' %> <div id="ajaxtitle">GET RELATED INFORMATION</div> <div id="menu"> <ul> <!-- calls method in a view''s helper for all the ajax details, put together in the application helper, of an array holding each hash of menu details. --> <% makemenu %> <% @menu.each do |menudetails| %> <li> <%= link_to_remote menudetails[:name], :update => ''ajaxarea'', :url => { :controller => menudetails[:link_controller], :action => menudetails[:link_action] }, :before => "$(''waiting'').show()", :success => "$(''div_part'').visualeffect(''highlight'')", :failure => "alert(''There was a failure, GOOFY!.'')", :complete => "$(''waiting'').hide()" %> </li> <% end %> </ul> </div> <span id="waiting" style="display: none;">WORK IN PROGRESS....HOLD ON, SHUT UP, AND SIT DOWN!</span> <div id="ajaxarea"> <!-- the ajax calls a controller, action, which renders an .rhtml page, inserted here. yeah! --> </div> -- 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 -~----------~----~----~----~------~----~------~--~---
So you want a different menu for different objects in your system? May I recommend using different layouts for the different objects. Say you have a CandyBarsController, just define: class CandyBarsController < ApplicationController layout ''candy_bars'' end I think that you might not even have to define the layout if the controller name is the same as the layout name, but I''m not sure on that :) On Dec 20, 2007 1:29 PM, gemblon (t.b.) <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > i was thinking, that for alot of my application, when i have a record, i > want a menu with all the related ajax calls linked to a that record. > there might me a gem to do this, or an easier way, but this is what i > did. i am open to new ideas, as this was made to work easily from any > view by calling a partial and setting up the ajax info in the helpers. > what do you all think about this type of DRY? is there another better > way? i got it working on link_to but now working on link_to_remote. > > views>layout>_menu.rhtml > > <!-- suckerfish css, VERY simple, to work in all browsers, i hope. --> > <%= stylesheet_link_tag ''ajaxmenu'' %> > > <div id="ajaxtitle">GET RELATED INFORMATION</div> > <div id="menu"> > <ul> > > <!-- calls method in a view''s helper for all the ajax details, put > together in the application helper, of an array holding each hash of > menu details. --> > <% makemenu %> > > <% @menu.each do |menudetails| %> > > <li> > <%= link_to_remote menudetails[:name], > :update => ''ajaxarea'', > :url => { :controller => menudetails[:link_controller], > :action => menudetails[:link_action] }, > :before => "$(''waiting'').show()", > :success => "$(''div_part'').visualeffect(''highlight'')", > :failure => "alert(''There was a failure, GOOFY!.'')", > :complete => "$(''waiting'').hide()" > %> > </li> > > <% end %> > </ul> > </div> > > <span id="waiting" style="display: none;">WORK IN PROGRESS....HOLD ON, > SHUT UP, AND SIT DOWN!</span> > > <div id="ajaxarea"> > <!-- the ajax calls a controller, action, which renders an .rhtml > page, inserted here. yeah! --> > </div> > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> So you want a different menu for different objects in your system? > > May I recommend using different layouts for the different objects. Say > you > have a CandyBarsController, just define: > > class CandyBarsController < ApplicationController > layout ''candy_bars'' > end > > I think that you might not even have to define the layout if the > controller > name is the same as the layout name, but I''m not sure on that :) > > -- > Ryan Bigg > http://www.frozenplague.nethi ryan, well, you are a lot smarter then me, so i might not be doing this right. in each controller, i already have a layout template, that is pretty complex. i need to use that. so, when i edit or show a record, i was gonna display the table data, and then, under that, show the menu for remote links. is that not good? -- 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 -~----------~----~----~----~------~----~------~--~---
Are you able to give me an example of what these remote links are? On Dec 20, 2007 1:51 PM, gemblon (t.b.) <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Ryan Bigg wrote: > > So you want a different menu for different objects in your system? > > > > May I recommend using different layouts for the different objects. Say > > you > > have a CandyBarsController, just define: > > > > class CandyBarsController < ApplicationController > > layout ''candy_bars'' > > end > > > > I think that you might not even have to define the layout if the > > controller > > name is the same as the layout name, but I''m not sure on that :) > > > > -- > > Ryan Bigg > > http://www.frozenplague.net > > hi ryan, > > well, you are a lot smarter then me, so i might not be doing this right. > in each controller, i already have a layout template, that is pretty > complex. > i need to use that. > > so, when i edit or show a record, i was gonna display the table data, > and then, under that, show the menu for remote links. > > is that not good? > > > > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> Are you able to give me an example of what these remote links are? >oops, sorry ryan... the helper file has: def makemenu @menu = [] #an ajax menu item = { :name => "Notes", :link_controller => "casefilenote", :link_action => "list" } @menu << item #an ajax menu item = { :name => "Case Events", :link_controller => "event", :link_action => "list" } @menu << item end it all seems to work nice, and is really fast to add ajax menu items. well, for my application. you just have to watch with layout you use in a controller, depending on what method is going to be called. is there a better way? -- 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 -~----------~----~----~----~------~----~------~--~---
gemblon (t.b.) wrote:> Ryan Bigg wrote:and i need to track what menu was selected. so i can gray the menu background. and fix up a few more things. i am installing in several places, and i will update it tomorrow if you want to see it in action. it is not perfectly clean yet, but that is just me doing some clean up. :) if you have another idea, let me know. i will try it on a table. :) -- 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 -~----------~----~----~----~------~----~------~--~---
We use something here to select which menu item is selected. I can''t show you the exact code, but basically you give the containing element of the link a class depending on an argument passed in. def menu_selected(menu_item) if menu_item == "edit" && params[:action] == "edit" "selected" end Then on your menu: <ul class=''menu''> <li class=''<%= menu_selected("edit") %>''>Edit</li> ... </ul> On Dec 20, 2007 2:24 PM, gemblon (t.b.) <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > gemblon (t.b.) wrote: > > Ryan Bigg wrote: > > > and i need to track what menu was selected. so i can gray the menu > background. and fix up a few more things. > > i am installing in several places, and i will update it tomorrow if you > want to see it in action. it is not perfectly clean yet, but that is > just me doing some clean up. > > :) > > if you have another idea, let me know. i will try it on a table. > > :) > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> We use something here to select which menu item is selected. I can''t > show > you the exact code, but basically you give the containing element of the > link a class depending on an argument passed in. > > def menu_selected(menu_item) > if menu_item == "edit" && params[:action] == "edit" > "selected" > end > > Then on your menu: > > <ul class=''menu''> > <li class=''<%= menu_selected("edit") %>''>Edit</li> > ... > </ul> > > > On Dec 20, 2007 2:24 PM, gemblon (t.b.) > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> just me doing some clean up. >> > >> > > > -- > Ryan Bigg > http://www.frozenplague.nethey ryan, that seems like a cool idea. i am gonna give it a try tomorrow. :) -- 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 -~----------~----~----~----~------~----~------~--~---