Dan Croak
2007-Aug-08 04:13 UTC
RJS creates JavaScript, which prints to screen instead of evaluating
I have a partial named "_mailing_list.rhtml" ~ <% remote_form_for(:recipient, :url=> { :controller => ''recipients'', :action => ''create'' }) do |f| %> <p> Email: <%= f.text_field :email_address, :size => 20 -%> <%= submit_tag "Subscribe", :disable_with => "Please wait..." %> </p> <% end %> I have a create action in my recipients controller ~ def create @recipient = Recipient.new(params[:recipient]) @recipient.save end I have a create.rjs ~ page[:mailing_list].reload The Recipient ActiveRecord correctly updates the database and the RJS creates the JavaScript I want, but rather than executing the JavaScript, I see it printed to my screen and the URL changed to / recipients/create What am I doing wrong? Thanks, Dan --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Daniel N
2007-Aug-08 05:07 UTC
Re: RJS creates JavaScript, which prints to screen instead of evaluating
On 8/8/07, Dan Croak <dan.croak-U0LLASLCtz+HOgEwjOSpYkB+6BGkLq7r@public.gmane.org> wrote:> > > I have a partial named "_mailing_list.rhtml" ~ > > <% remote_form_for(:recipient, :url=> { :controller => > ''recipients'', :action => ''create'' }) do |f| %> > <p> > Email: <%= f.text_field :email_address, :size => 20 -%> > <%= submit_tag "Subscribe", :disable_with => "Please wait..." %> > </p> > <% end %> > > I have a create action in my recipients controller ~ > > def create > @recipient = Recipient.new(params[:recipient]) > @recipient.save > end > > I have a create.rjs ~ > > page[:mailing_list].reload > > The Recipient ActiveRecord correctly updates the database and the RJS > creates the JavaScript I want, but rather than executing the > JavaScript, I see it printed to my screen and the URL changed to / > recipients/create > > What am I doing wrong? > > Thanks, > DanHave you included the prototype.js library in your layout? <%= javascript_include_tag :defaults -%> HTH Daniel --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Dan Croak
2007-Aug-08 05:09 UTC
Re: RJS creates JavaScript, which prints to screen instead of evaluating
Yes, and the source file shows prototype.js, etc. included. On Aug 8, 1:07 am, "Daniel N" <has....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Have you included the prototype.js library in your layout? > > <%= javascript_include_tag :defaults -%> > > HTH > Daniel--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
sina
2007-Aug-11 01:16 UTC
Re: RJS creates JavaScript, which prints to screen instead of evaluating
Have you updated the default javascript files since you created your rails project? I don''t know exactly why that might break your code, but I had the same problem you''re describing after I tried to update the prototype and scriptaculous files to the latest versions. Once I reverted back to what shipped with my version of Rails, my RJS templates worked again. On Aug 7, 10:09 pm, Dan Croak <dan.cr...-U0LLASLCtz+HOgEwjOSpYkB+6BGkLq7r@public.gmane.org> wrote:> Yes, and the source file shows prototype.js, etc. included. > > On Aug 8, 1:07 am, "Daniel N" <has....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Have you included the prototype.js library in your layout? > > > <%= javascript_include_tag :defaults -%> > > > HTH > > Daniel--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---