For all my applicatino I use layout A. In this layout I have <%= javascript_include_tag ''application.js'' %> and, in this javascript I have some code that I want to execute on all pages exept one. How can I exclude this javascript only for one page? -- 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.
On 22 December 2010 15:56, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For all my applicatino I use layout A. > In this layout I have <%= javascript_include_tag ''application.js'' %> > and, in this javascript I have some code that I want to execute on all > pages exept one. > How can I exclude this javascript only for one page?You could extract that code to a separate .js file and have a separate layout for that page that does not include the new js file. Colin -- 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.
On 22 December 2010 17:22, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 22 December 2010 15:56, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> For all my applicatino I use layout A. >> In this layout I have <%= javascript_include_tag ''application.js'' %> >> and, in this javascript I have some code that I want to execute on all >> pages exept one. >> How can I exclude this javascript only for one page? > > You could extract that code to a separate .js file and have a separate > layout for that page that does not include the new js file.But I have to duplicate the layout code only to not include a .js? All the pages have the same layout. -- 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.
On 22 December 2010 16:24, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 22 December 2010 17:22, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 22 December 2010 15:56, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> For all my applicatino I use layout A. >>> In this layout I have <%= javascript_include_tag ''application.js'' %> >>> and, in this javascript I have some code that I want to execute on all >>> pages exept one. >>> How can I exclude this javascript only for one page? >> >> You could extract that code to a separate .js file and have a separate >> layout for that page that does not include the new js file. > > But I have to duplicate the layout code only to not include a .js? > All the pages have the same layout.Put all the common stuff in a separate file or files and yield to it/them from the layouts. Colin -- 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.
Frederick Cheung
2010-Dec-22 16:29 UTC
Re: javascript code execution on all pages except one.
On Dec 22, 4:24 pm, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 22 December 2010 17:22, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > On 22 December 2010 15:56, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> For all my applicatino I use layout A. > >> In this layout I have <%= javascript_include_tag ''application.js'' %> > >> and, in this javascript I have some code that I want to execute on all > >> pages exept one. > >> How can I exclude this javascript only for one page? > > > You could extract that code to a separate .js file and have a separate > > layout for that page that does not include the new js file. > > But I have to duplicate the layout code only to not include a .js? > All the pages have the same layout.You could stick <%= yield :extra_js %> in the head section of the layout and then use content_for :extra_js with the include for the extra javascript file Fred -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 22 December 2010 17:29, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You could stick <%= yield :extra_js %> in the head section of the > layout and then use content_for :extra_js with the include for the > extra javascript file >Yes that''s a solution, thank you. -- 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.
On 22 December 2010 17:31, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 22 December 2010 17:29, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> You could stick <%= yield :extra_js %> in the head section of the >> layout and then use content_for :extra_js with the include for the >> extra javascript fileCan I use content_for in a partial too? -- 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.
On Dec 22, 11:37 am, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Can I use content_for in a partial too?Are you asking because you tried it and it didn''t work? I don''t see anything in the documentation that indicates it would NOT work in a partial. -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Garrett Lancaster
2010-Dec-22 20:26 UTC
Re: Re: javascript code execution on all pages except one.
It should work in partials, but will not work if you are rendering the partial in an ajax call On Dec 22, 2010, at 1:58 PM, E. Litwin wrote:> On Dec 22, 11:37 am, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Can I use content_for in a partial too? > > Are you asking because you tried it and it didn''t work? > > I don''t see anything in the documentation that indicates it would NOT > work in a partial. > > -- > 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. >-- 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.
On 22 December 2010 20:58, E. Litwin <elitwin-ur4TIblo6goN+BqQ9rBEUg@public.gmane.org> wrote:> On Dec 22, 11:37 am, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Can I use content_for in a partial too? > > Are you asking because you tried it and it didn''t work? >Yes -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.