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.
Claus G. (Guest)
on 2006-03-17 14: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
Tom D. (Guest)
on 2006-03-17 14:48
(Received via mailing list)
Try this:
<head>
  <%= javascript_include_tag :defaults %>
</head>




On 3/17/06, Claus G. <removed_email_address@domain.invalid> wrote:
> The search-field is in app/views/demo/observer.rthml and I have to
>
--
Tom D.

http://blog.atomgiant.com
http://gifthat.com
Claus G. (Guest)
on 2006-03-17 19: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
Tom D. (Guest)
on 2006-03-17 22: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 G. <removed_email_address@domain.invalid> wrote:
> Claus
> > > does'nt work when I include the line in my
> > > Rails mailing list
> > _______________________________________________
> > Rails mailing list
> > removed_email_address@domain.invalid
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> >
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Tom D.

http://blog.atomgiant.com
http://gifthat.com
Claus G. (Guest)
on 2006-03-18 00: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.