I am testing a local copy of my website using Mongrel trying to introduce a scriptaculous multi-level drop down menu. the menu is a partial that is loaded into every layout I have many pages with their individual layout file. When I jump from page to page(index to index) all works OK. When I jump from any "view/index" to "view/show" I lose the javascript and the drop down menu only works on the first level. Can anyone shed some light on why this happens and how I can solve it. In my layouts heads I have the following:- <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <title>Blogpictures: <%= controller.action_name %></title> <%= stylesheet_link_tag ''style'' %> <script src="javascripts/prototype.js" type="text/javascript"></ script> <script src="javascripts/scriptaculous.js" type="text/javascript"></script> <script type=''text/javascript'' src=''javascripts/menu.js''></script> </head> In the source html both index and show has exactly the same head (except title) I am using the control.js protype.js etc that came with the scriptaculous download also using the latest versions of Ruby, Rails, Gems etc Gems etc. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
pharrington
2009-Nov-29 17:44 UTC
Re: Views/index to views/show loses javascript functionality
On Nov 29, 9:56 am, MDM <don.m...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am testing a local copy of my website using Mongrel trying to > introduce a scriptaculous multi-level drop down menu. the menu is a > partial that is loaded into every layout I have many pages with their > individual layout file. When I jump from page to page(index to index) > all works OK. When I > jump from any "view/index" to "view/show" I lose the javascript and > the > drop down menu only works on the first level. Can anyone shed some > light > on why this happens and how I can solve it. In my layouts heads I have > the following:- > <head> > <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> > <title>Blogpictures: <%= controller.action_name %></title> > <%= stylesheet_link_tag ''style'' %> > > <script src="javascripts/prototype.js" type="text/javascript"></ > script> > <script src="javascripts/scriptaculous.js" > type="text/javascript"></script> > <script type=''text/javascript'' src=''javascripts/menu.js''></script> > </head>Those are relative paths, and almost certainly only work from the root of your site. It greatly helps when developing to use a tool like Firebug which will show you that the javascript files are 404ing. And is there a reason you''re not using javascript_include_tag?> In the source html both index and show has exactly the same head > (except title) > I am using the control.js protype.js etc that came with the > scriptaculous download also using the latest versions of Ruby, Rails, > Gems etc > Gems etc.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 that I am not an expert Ruby on Rails programmer. I suspect that the "show" is relative to the "index" and the index is relative to the root. I will go and read up on Javascript_include_tag. I do use firebug and oops! yes it is flagging a 404 error. now to solve it. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for the above javascript_include_tag solved the problem. I should learn to use Ruby all the time instead of a mixture of ruby and HTML. Thanks againThanks for the above javascript_include_tag solved the problem. I should learn to use Ruby all the time instead of a mixture of ruby and HTML. Thanks again -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.