I am loading a partial via AJAX in my Rails 3 app. I want to have some partial related JS loaded when that partial loads so that I am only loading JS when needed. No matter what I do, I cannot get the JS <script> elements to render. I have used variations of the Rails javascript load helpers as well as straight up <script> tags. No matter what I do when I look at the markup loaded by AJAX I never see my <script> tags. I can always load css that''s part of the partial just fine, but never JS. What''s going on here? Thanks, Elliott G -- 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.
Walter Davis
2011-Jun-08 02:13 UTC
Re: Unable to call JS scripts from a partial loaded via AJAX
On Jun 7, 2011, at 10:05 PM, elliottg wrote:> I am loading a partial via AJAX in my Rails 3 app. I want to have some > partial related JS loaded when that partial loads so that I am only > loading JS when needed. > > No matter what I do, I cannot get the JS <script> elements to render. > I have used variations of the Rails javascript load helpers as well as > straight up <script> tags. No matter what I do when I look at the > markup loaded by AJAX I never see my <script> tags. > > I can always load css that''s part of the partial just fine, but never > JS. > > What''s going on here?Prototype strips out inline scripts unless you set the property evalScripts:true inside your Ajax parameters. In the Rails helper, that''s probably done by adding :eval_scripts => true somewhere, give that a try. Walter> > Thanks, Elliott G > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@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.
elliottg
2011-Jun-08 03:42 UTC
Re: Unable to call JS scripts from a partial loaded via AJAX
Thanks for the input Walter, I think this will set me in the right direction. While I have your ear, do you know the solution for jQuery? I am seeing a bit about .load() have some tag stripping issues but have yet to find the solution. Thanks, EG -- 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.