Hi. I copied the layout-example from agile web dev. in rails. When I want to use ajax to create a search field including <head><%= javascript_include_tag "prototype" %></head> does''nt work when I include the line in my app/views/layout/demo.rhtml. Name of controller is demo_controller.rb. The search-field is in app/views/demo/observer.rthml and I have to include the above mentioned line in this file to "ajax-enable" the search-field. Should''nt it be possible to include it from a layout-file? regards Claus
Try this: <head> <%= javascript_include_tag :defaults %> </head> On 3/17/06, Claus Guttesen <kometen@gmail.com> wrote:> Hi. > > I copied the layout-example from agile web dev. in rails. When I want > to use ajax to create a search field including > > <head><%= javascript_include_tag "prototype" %></head> > > does''nt work when I include the line in my > app/views/layout/demo.rhtml. Name of controller is demo_controller.rb. > > The search-field is in app/views/demo/observer.rthml and I have to > include the above mentioned line in this file to "ajax-enable" the > search-field. Should''nt it be possible to include it from a > layout-file? > > regards > Claus > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tom Davies http://blog.atomgiant.com http://gifthat.com
> Try this: > <head> > <%= javascript_include_tag :defaults %> > </head>Thank you so much! :-) How come "prototype" does not work? regards Claus> On 3/17/06, Claus Guttesen <kometen@gmail.com> wrote: > > Hi. > > > > I copied the layout-example from agile web dev. in rails. When I want > > to use ajax to create a search field including > > > > <head><%= javascript_include_tag "prototype" %></head> > > > > does''nt work when I include the line in my > > app/views/layout/demo.rhtml. Name of controller is demo_controller.rb. > > > > The search-field is in app/views/demo/observer.rthml and I have to > > include the above mentioned line in this file to "ajax-enable" the > > search-field. Should''nt it be possible to include it from a > > layout-file? > > > > regards > > Claus > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Tom Davies > > http://blog.atomgiant.com > http://gifthat.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi Claus, Glad that worked for you. Your include "prototype" should have successfully included the prototype library. I tested it on mine and it rendered: <script src="/javascripts/prototype.js" type="text/javascript"></script> which should work. I am guessing that what you are trying to do depends on some of the helper libraries as well. If you view the source of your generated page you will see all of these get included with the :defaults: <script src="/javascripts/prototype.js" type="text/javascript"></script> <script src="/javascripts/effects.js" type="text/javascript"></script> <script src="/javascripts/dragdrop.js" type="text/javascript"></script> <script src="/javascripts/controls.js" type="text/javascript"></script> Tom On 3/17/06, Claus Guttesen <kometen@gmail.com> wrote:> > Try this: > > <head> > > <%= javascript_include_tag :defaults %> > > </head> > > Thank you so much! :-) > > How come "prototype" does not work? > > regards > Claus > > > > On 3/17/06, Claus Guttesen <kometen@gmail.com> wrote: > > > Hi. > > > > > > I copied the layout-example from agile web dev. in rails. When I want > > > to use ajax to create a search field including > > > > > > <head><%= javascript_include_tag "prototype" %></head> > > > > > > does''nt work when I include the line in my > > > app/views/layout/demo.rhtml. Name of controller is demo_controller.rb. > > > > > > The search-field is in app/views/demo/observer.rthml and I have to > > > include the above mentioned line in this file to "ajax-enable" the > > > search-field. Should''nt it be possible to include it from a > > > layout-file? > > > > > > regards > > > Claus > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > Tom Davies > > > > http://blog.atomgiant.com > > http://gifthat.com > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tom Davies http://blog.atomgiant.com http://gifthat.com
> Your include "prototype" should have successfully included the > prototype library. I tested it on mine and it rendered: > > <script src="/javascripts/prototype.js" type="text/javascript"></script> > > which should work.Well, the thing is that you are once again correct in your assumption. I first did the change to :default and opened the page in firefox''s javascript-console. There I found the "fabulous four" mentioned below.> <script src="/javascripts/prototype.js" type="text/javascript"></script> > <script src="/javascripts/effects.js" type="text/javascript"></script> > <script src="/javascripts/dragdrop.js" type="text/javascript"></script> > <script src="/javascripts/controls.js" type="text/javascript"></script>Then I changed back to "prototype" in the layout-rhtml and it still works. So either I spelled it wrong or some caching in the browser or lighttpd took place. regards Claus