Forum: Ruby on Rails using ajax and layouts

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-03-17 13:24
(Received via mailing list)
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
22580f640e491f0920a192610d1df393?d=identicon&s=25 Tom Davies (Guest)
on 2006-03-17 13:48
(Received via mailing list)
Try this:
<head>
  <%= javascript_include_tag :defaults %>
</head>




On 3/17/06, Claus Guttesen <kometen@gmail.com> wrote:
> The search-field is in app/views/demo/observer.rthml and I have to
>
--
Tom Davies

http://blog.atomgiant.com
http://gifthat.com
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-03-17 18:40
(Received via mailing list)
> Try this:
> <head>
>   <%= javascript_include_tag :defaults %>
> </head>

Thank you so much! :-)

How come "prototype" does not work?

regards
Claus
22580f640e491f0920a192610d1df393?d=identicon&s=25 Tom Davies (Guest)
on 2006-03-17 21:56
(Received via mailing list)
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:
> Claus
> > > does'nt work when I include the line in my
> > > Rails mailing list
> > _______________________________________________
> > 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
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-03-17 23:19
(Received via mailing list)
> 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
This topic is locked and can not be replied to.