On 9 May 2011 14:30, Sergio Ruiz
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> i saw on one of the railscasts that using unobtrusive javascript, you
> attach your javascript to your page like so:
>
> if your view is:
>
> index.html.erb
>
> you could add a page named:
>
> index.js.erb
>
> and that javascript would be included on the load for that page.
>
> for some reason, it is not working for me..
>
> is there something i need to do to trigger this behavior?
There is no such behaviour in Rails; I think you might have
misunderstood the screencast.
Assuming you are talking about this:
http://asciicasts.com/episodes/205-unobtrusive-javascript
then the ''index.js.erb'' is rendered when your browser makes an
AJAX
request to the ''index'' action (in the same way that
''index.html.erb''
is rendered when your browser makes an ordinary request to the index
action).
These are two completely separate requests. index.js.erb is *not*
being inserted into a script tag in index.html.erb.
If you want that kind of thing to happen, you''ll need to write a
custom view helper (and probably choose a more appropriate path for
your automatically-included JavaScript files, so that they don''t
conflict with the standard behaviour described above).
Chris
--
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.