Forum: Ruby on Rails javascript_include within single views

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.
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2008-12-12 03:40
(Received via mailing list)
Are you allowed to use the javascript_include_tag to include
javascript files for specific views?  I have included the default
javascript files in the <head> element of my site layout file, but
when I try and include a javascript file for a specific view within a
new <head> element in that view it does not work.  I guess my question
is: is it okay to create separate <head> elements for specific views?
Will all the code get rendered that is within these new <head>
elements and the <head> elements in my layout file?  or will there be
a conflict?
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2008-12-12 03:55
(Received via mailing list)
On Thu, Dec 11, 2008 at 6:40 PM, David <dlynam@gmail.com> wrote:

>
> Are you allowed to use the javascript_include_tag to include
> javascript files for specific views?  I have included the default
> javascript files in the <head> element of my site layout file, but
> when I try and include a javascript file for a specific view within a
> new <head> element in that view it does not work.  I guess my question
> is: is it okay to create separate <head> elements for specific views?
> Will all the code get rendered that is within these new <head>
> elements and the <head> elements in my layout file?  or will there be
> a conflict?


Yes, you are allowed to use the javascript_include_tag to include
javascript
files for specific view templates.  Can you post your code so that
people
can better assist you because I don't follow your question.

-Conrad
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2008-12-12 08:51
(Received via mailing list)
so would the following be redundant then?

<% content_for :javascript do %>
  <%= javascript_tag "new javascript function" %>
<% end %>

assuming i have <%= yield :javascript %>

in my main layout file.
453493fcee22adbf3c46ac793a346ef5?d=identicon&s=25 Nike Mike (nike)
on 2008-12-12 10:12
David wrote:
> so would the following be redundant then?
>
> <% content_for :javascript do %>
>   <%= javascript_tag "new javascript function" %>
> <% end %>
>
> assuming i have <%= yield :javascript %>
>
> in my main layout file.

Please study this tutorail

http://railscasts.com/episodes/8-layouts-and-content-for
This topic is locked and can not be replied to.