Using ajax and layouts


#1

Hi.

I copied the layout-example from agile web dev. in rails. When I want
to use ajax to create a search field including

<%= javascript_include_tag "prototype" %>

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


#2

Try this:

<%= javascript_include_tag :defaults %>

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


#3

Try this:

<%= javascript_include_tag :defaults %>

Thank you so much! :slight_smile:

How come “prototype” does not work?

regards
Claus


#4

Your include “prototype” should have successfully included the
prototype library. I tested it on mine and it rendered:

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.

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


#5

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:

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:

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