This seems like it should be pretty straightforward, but its stumping me. I have a small form that I am trying to submit using jquery that is supposed to remove an association between to HABTM models. For the sake of argument, the models are Course and Student. # view <%= form_tag ( remove_student_from_course_path, :remote => true ) %> <%= hidden_field_tag "course_id", @course.id %> <%= hidden_field_tag "student_id", @student.id %> <%= submit_tag ''Remove'' %> # controller def remove_student_from_class @student = Student.find(params[:student_id]) @msg = Factor.method_to_remove_student_from_class(params) respond_to do |format| format.html { redirect_to edit_class_path(@class) } format.js end end # remove_student_from_class.js.erb // reload the page location.reload(); Everything works fine, except the HTML code is generated and not the JS code in the respond_to block. I would expect the JS call to get fired since I have the '':remote => true'' line in there, but its always the HTML and it generates the page. What am I overlooking? Dave -- 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.
Are you including rails.js? On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This seems like it should be pretty straightforward, but its stumping > me. I have a small form that I am trying to submit using jquery that > is supposed to remove an association between to HABTM models. For the > sake of argument, the models are Course and Student. > > # view > <%= form_tag ( remove_student_from_course_path, :remote => true ) > %> > <%= hidden_field_tag "course_id", @course.id %> > <%= hidden_field_tag "student_id", @student.id %> > <%= submit_tag ''Remove'' %> > > # controller > def remove_student_from_class > @student = Student.find(params[:student_id]) > @msg = Factor.method_to_remove_student_from_class(params) > > respond_to do |format| > format.html { redirect_to edit_class_path(@class) } > format.js > end > end > > # remove_student_from_class.js.erb > // reload the page > location.reload(); > > Everything works fine, except the HTML code is generated and not the > JS code in the respond_to block. I would expect the JS call to get > fired since I have the '':remote => true'' line in there, but its always > the HTML and it generates the page. What am I overlooking? > > Dave-- 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.
Yes I am, here''s what I have in the application.html.erb view, and they are all in my javascript folder <%= javascript_include_tag ''jquery-1.4.3.js'', ''rails'', ''application'' %> On Dec 15, 10:30 pm, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you including rails.js? > > On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > This seems like it should be pretty straightforward, but its stumping > > me. I have a small form that I am trying to submit using jquery that > > is supposed to remove an association between to HABTM models. For the > > sake of argument, the models are Course and Student. > > > # view > > <%= form_tag ( remove_student_from_course_path, :remote => true ) > > %> > > <%= hidden_field_tag "course_id", @course.id %> > > <%= hidden_field_tag "student_id", @student.id %> > > <%= submit_tag ''Remove'' %> > > > # controller > > def remove_student_from_class > > @student = Student.find(params[:student_id]) > > @msg = Factor.method_to_remove_student_from_class(params) > > > respond_to do |format| > > format.html { redirect_to edit_class_path(@class) } > > format.js > > end > > end > > > # remove_student_from_class.js.erb > > // reload the page > > location.reload(); > > > Everything works fine, except the HTML code is generated and not the > > JS code in the respond_to block. I would expect the JS call to get > > fired since I have the '':remote => true'' line in there, but its always > > the HTML and it generates the page. What am I overlooking? > > > Dave-- 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 Dec 16, 2010, at 12:48 AM, loominator1970 wrote:> Yes I am, here''s what I have in the application.html.erb view, and > they are all in my javascript folder > > <%= javascript_include_tag ''jquery-1.4.3.js'', ''rails'', ''application'' > %>Ah, but have you replaced rails.js with the jquery version? curl -O https://github.com/rails/jquery-ujs/raw/master/src/rails.js see the README at http://github.com/rails/jquery-ujs for more details. -Rob> On Dec 15, 10:30 pm, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Are you including rails.js? >> >> On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> This seems like it should be pretty straightforward, but its >>> stumping >>> me. I have a small form that I am trying to submit using jquery >>> that >>> is supposed to remove an association between to HABTM models. For >>> the >>> sake of argument, the models are Course and Student. >> >>> # view >>> <%= form_tag ( remove_student_from_course_path, :remote => >>> true ) >>> %> >>> <%= hidden_field_tag "course_id", @course.id %> >>> <%= hidden_field_tag "student_id", @student.id %> >>> <%= submit_tag ''Remove'' %> >> >>> # controller >>> def remove_student_from_class >>> @student = Student.find(params[:student_id]) >>> @msg = Factor.method_to_remove_student_from_class(params) >> >>> respond_to do |format| >>> format.html { redirect_to edit_class_path(@class) } >>> format.js >>> end >>> end >> >>> # remove_student_from_class.js.erb >>> // reload the page >>> location.reload(); >> >>> Everything works fine, except the HTML code is generated and not the >>> JS code in the respond_to block. I would expect the JS call to get >>> fired since I have the '':remote => true'' line in there, but its >>> always >>> the HTML and it generates the page. What am I overlooking? >> >>> DaveRob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/ -- 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.
Yep, i''ve done that, too. Here''s the header of the ''rails.js'' version i''m using /* * jquery-ujs * * http://github.com/rails/jquery-ujs/blob/master/src/rails.js * * This rails.js file supports jQuery 1.4.3 and 1.4.4 . * */ On Dec 15, 11:08 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Dec 16, 2010, at 12:48 AM, loominator1970 wrote: > > > Yes I am, here''s what I have in the application.html.erb view, and > > they are all in my javascript folder > > > <%= javascript_include_tag ''jquery-1.4.3.js'', ''rails'', ''application'' > > %> > > Ah, but have you replaced rails.js with the jquery version? > > curl -Ohttps://github.com/rails/jquery-ujs/raw/master/src/rails.js > > see the README athttp://github.com/rails/jquery-ujsfor more details. > > -Rob > > > > > > > > > > > On Dec 15, 10:30 pm, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Are you including rails.js? > > >> On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>> This seems like it should be pretty straightforward, but its > >>> stumping > >>> me. I have a small form that I am trying to submit using jquery > >>> that > >>> is supposed to remove an association between to HABTM models. For > >>> the > >>> sake of argument, the models are Course and Student. > > >>> # view > >>> <%= form_tag ( remove_student_from_course_path, :remote => > >>> true ) > >>> %> > >>> <%= hidden_field_tag "course_id", @course.id %> > >>> <%= hidden_field_tag "student_id", @student.id %> > >>> <%= submit_tag ''Remove'' %> > > >>> # controller > >>> def remove_student_from_class > >>> @student = Student.find(params[:student_id]) > >>> @msg = Factor.method_to_remove_student_from_class(params) > > >>> respond_to do |format| > >>> format.html { redirect_to edit_class_path(@class) } > >>> format.js > >>> end > >>> end > > >>> # remove_student_from_class.js.erb > >>> // reload the page > >>> location.reload(); > > >>> Everything works fine, except the HTML code is generated and not the > >>> JS code in the respond_to block. I would expect the JS call to get > >>> fired since I have the '':remote => true'' line in there, but its > >>> always > >>> the HTML and it generates the page. What am I overlooking? > > >>> Dave > > Rob Biedenharn > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ > r...-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/-- 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.
Do you have anything pertinent/related/involved in the application.js file? Try pulling that out as you could be having a failure in JS that''s causing grief. Also -- check your console in Firebug (or whatever you''re using) and see if errors are being thrown when the page loads. On Dec 16, 1:19 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yep, i''ve done that, too. Here''s the header of the ''rails.js'' version > i''m using > > /* > * jquery-ujs > * > *http://github.com/rails/jquery-ujs/blob/master/src/rails.js > * > * This rails.js file supports jQuery 1.4.3 and 1.4.4 . > * > */ > > On Dec 15, 11:08 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > wrote: > > > > > > > > > On Dec 16, 2010, at 12:48 AM, loominator1970 wrote: > > > > Yes I am, here''s what I have in the application.html.erb view, and > > > they are all in my javascript folder > > > > <%= javascript_include_tag ''jquery-1.4.3.js'', ''rails'', ''application'' > > > %> > > > Ah, but have you replaced rails.js with the jquery version? > > > curl -Ohttps://github.com/rails/jquery-ujs/raw/master/src/rails.js > > > see the README athttp://github.com/rails/jquery-ujsformore details. > > > -Rob > > > > On Dec 15, 10:30 pm, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> Are you including rails.js? > > > >> On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >>> This seems like it should be pretty straightforward, but its > > >>> stumping > > >>> me. I have a small form that I am trying to submit using jquery > > >>> that > > >>> is supposed to remove an association between to HABTM models. For > > >>> the > > >>> sake of argument, the models are Course and Student. > > > >>> # view > > >>> <%= form_tag ( remove_student_from_course_path, :remote => > > >>> true ) > > >>> %> > > >>> <%= hidden_field_tag "course_id", @course.id %> > > >>> <%= hidden_field_tag "student_id", @student.id %> > > >>> <%= submit_tag ''Remove'' %> > > > >>> # controller > > >>> def remove_student_from_class > > >>> @student = Student.find(params[:student_id]) > > >>> @msg = Factor.method_to_remove_student_from_class(params) > > > >>> respond_to do |format| > > >>> format.html { redirect_to edit_class_path(@class) } > > >>> format.js > > >>> end > > >>> end > > > >>> # remove_student_from_class.js.erb > > >>> // reload the page > > >>> location.reload(); > > > >>> Everything works fine, except the HTML code is generated and not the > > >>> JS code in the respond_to block. I would expect the JS call to get > > >>> fired since I have the '':remote => true'' line in there, but its > > >>> always > > >>> the HTML and it generates the page. What am I overlooking? > > > >>> Dave > > > Rob Biedenharn > > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ > > r...-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/-- 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.
Nope, nothing in the application.js file. Checked the firebug output and there is nothing. The JS is not even getting fired, which make no sense because I have the '':remote => true'' statement in there. It even creates the ''data-remote'' call in the HTML output (see below). I thought that was the key to UJS in Rails3? <form accept-charset="UTF-8" action="/course/ remove_student_from_course" data-remote="true" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="4uzcKHN73cndlQENeb7IWRhe6g0F5eFZG91y3ACWO0M=" /></ div> <input id="course_id" name="course_id" type="hidden" value="1529" /> <input id="student_id" name="student_id" type="hidden" value="437" /> <input class="submitLink" name="commit" type="submit" value="Remove" /> </form> On Dec 16, 1:34 am, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Do you have anything pertinent/related/involved in the application.js > file? Try pulling that out as you could be having a failure in JS > that''s causing grief. Also -- check your console in Firebug (or > whatever you''re using) and see if errors are being thrown when the > page loads. > > On Dec 16, 1:19 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Yep, i''ve done that, too. Here''s the header of the ''rails.js'' version > > i''m using > > > /* > > * jquery-ujs > > * > > *http://github.com/rails/jquery-ujs/blob/master/src/rails.js > > * > > * This rails.js file supports jQuery 1.4.3 and 1.4.4 . > > * > > */ > > > On Dec 15, 11:08 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > > wrote: > > > > On Dec 16, 2010, at 12:48 AM, loominator1970 wrote: > > > > > Yes I am, here''s what I have in the application.html.erb view, and > > > > they are all in my javascript folder > > > > > <%= javascript_include_tag ''jquery-1.4.3.js'', ''rails'', ''application'' > > > > %> > > > > Ah, but have you replaced rails.js with the jquery version? > > > > curl -Ohttps://github.com/rails/jquery-ujs/raw/master/src/rails.js > > > > see the README athttp://github.com/rails/jquery-ujsformoredetails. > > > > -Rob > > > > > On Dec 15, 10:30 pm, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> Are you including rails.js? > > > > >> On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > >>> This seems like it should be pretty straightforward, but its > > > >>> stumping > > > >>> me. I have a small form that I am trying to submit using jquery > > > >>> that > > > >>> is supposed to remove an association between to HABTM models. For > > > >>> the > > > >>> sake of argument, the models are Course and Student. > > > > >>> # view > > > >>> <%= form_tag ( remove_student_from_course_path, :remote => > > > >>> true ) > > > >>> %> > > > >>> <%= hidden_field_tag "course_id", @course.id %> > > > >>> <%= hidden_field_tag "student_id", @student.id %> > > > >>> <%= submit_tag ''Remove'' %> > > > > >>> # controller > > > >>> def remove_student_from_class > > > >>> @student = Student.find(params[:student_id]) > > > >>> @msg = Factor.method_to_remove_student_from_class(params) > > > > >>> respond_to do |format| > > > >>> format.html { redirect_to edit_class_path(@class) } > > > >>> format.js > > > >>> end > > > >>> end > > > > >>> # remove_student_from_class.js.erb > > > >>> // reload the page > > > >>> location.reload(); > > > > >>> Everything works fine, except the HTML code is generated and not the > > > >>> JS code in the respond_to block. I would expect the JS call to get > > > >>> fired since I have the '':remote => true'' line in there, but its > > > >>> always > > > >>> the HTML and it generates the page. What am I overlooking? > > > > >>> Dave > > > > Rob Biedenharn > > > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ > > > r...-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/-- 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.
I''m sure you checked this but just in case... based on what you just said, check to make sure you haven''t disabled JS in your browser. Put a "Hello World" script in Application.js I''m using jQuery in Rails 3 with Ruby 1.9.2 and it''s working fine: I use <%= javascript_include_tag :default %> with :default defined as config.action_view.javascript_expansions[:defaults] %w(jquery.min rails jquery-ui.min) in my application.rb file. HTH, Dan On Dec 16, 3:07 pm, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Nope, nothing in the application.js file. Checked the firebug output > and there is nothing. The JS is not even getting fired, which make no > sense because I have the '':remote => true'' statement in there. It > even creates the ''data-remote'' call in the HTML output (see below). I > thought that was the key to UJS in Rails3? > > <form accept-charset="UTF-8" action="/course/ > remove_student_from_course" data-remote="true" method="post"><div > style="margin:0;padding:0;display:inline"><input name="utf8" > type="hidden" value="✓" /><input name="authenticity_token" > type="hidden" value="4uzcKHN73cndlQENeb7IWRhe6g0F5eFZG91y3ACWO0M=" /></ > div> > <input id="course_id" name="course_id" type="hidden" > value="1529" /> > <input id="student_id" name="student_id" type="hidden" > value="437" /> > <input class="submitLink" name="commit" type="submit" > value="Remove" /> > </form> > > On Dec 16, 1:34 am, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Do you have anything pertinent/related/involved in the application.js > > file? Try pulling that out as you could be having a failure in JS > > that''s causing grief. Also -- check your console in Firebug (or > > whatever you''re using) and see if errors are being thrown when the > > page loads. > > > On Dec 16, 1:19 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Yep, i''ve done that, too. Here''s the header of the ''rails.js'' version > > > i''m using > > > > /* > > > * jquery-ujs > > > * > > > *http://github.com/rails/jquery-ujs/blob/master/src/rails.js > > > * > > > * This rails.js file supports jQuery 1.4.3 and 1.4.4 . > > > * > > > */ > > > > On Dec 15, 11:08 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > > > wrote: > > > > > On Dec 16, 2010, at 12:48 AM, loominator1970 wrote: > > > > > > Yes I am, here''s what I have in the application.html.erb view, and > > > > > they are all in my javascript folder > > > > > > <%= javascript_include_tag ''jquery-1.4.3.js'', ''rails'', ''application'' > > > > > %> > > > > > Ah, but have you replaced rails.js with the jquery version? > > > > > curl -Ohttps://github.com/rails/jquery-ujs/raw/master/src/rails.js > > > > > see the README athttp://github.com/rails/jquery-ujsformoredetails. > > > > > -Rob > > > > > > On Dec 15, 10:30 pm, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > >> Are you including rails.js? > > > > > >> On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > >>> This seems like it should be pretty straightforward, but its > > > > >>> stumping > > > > >>> me. I have a small form that I am trying to submit using jquery > > > > >>> that > > > > >>> is supposed to remove an association between to HABTM models. For > > > > >>> the > > > > >>> sake of argument, the models are Course and Student. > > > > > >>> # view > > > > >>> <%= form_tag ( remove_student_from_course_path, :remote => > > > > >>> true ) > > > > >>> %> > > > > >>> <%= hidden_field_tag "course_id", @course.id %> > > > > >>> <%= hidden_field_tag "student_id", @student.id %> > > > > >>> <%= submit_tag ''Remove'' %> > > > > > >>> # controller > > > > >>> def remove_student_from_class > > > > >>> @student = Student.find(params[:student_id]) > > > > >>> @msg = Factor.method_to_remove_student_from_class(params) > > > > > >>> respond_to do |format| > > > > >>> format.html { redirect_to edit_class_path(@class) } > > > > >>> format.js > > > > >>> end > > > > >>> end > > > > > >>> # remove_student_from_class.js.erb > > > > >>> // reload the page > > > > >>> location.reload(); > > > > > >>> Everything works fine, except the HTML code is generated and not the > > > > >>> JS code in the respond_to block. I would expect the JS call to get > > > > >>> fired since I have the '':remote => true'' line in there, but its > > > > >>> always > > > > >>> the HTML and it generates the page. What am I overlooking? > > > > > >>> Dave > > > > > Rob Biedenharn > > > > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ > > > > r...-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/-- 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.
Yep, Javascript is enabled, and working fine. Apparently, I have stumped the brightest minds in the rails world :) That can only mean one thing...i''m overlooking something very simple and I''ll feel quite dumb when the answer is presented to me :) On Dec 16, 3:09 pm, dsadaka <d...-faHGhEMRMREnEVtka5Vzhw@public.gmane.org> wrote:> I''m sure you checked this but just in case... based on what you just > said, check to make sure you haven''t disabled JS in your browser. > Put a "Hello World" script in Application.js > > I''m using jQuery in Rails 3 with Ruby 1.9.2 and it''s working fine: > > I use <%= javascript_include_tag :default %> with :default defined as > > config.action_view.javascript_expansions[:defaults] > %w(jquery.min rails jquery-ui.min) > > in my application.rb file. > > HTH, > Dan > > On Dec 16, 3:07 pm, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Nope, nothing in the application.js file. Checked the firebug output > > and there is nothing. The JS is not even getting fired, which make no > > sense because I have the '':remote => true'' statement in there. It > > even creates the ''data-remote'' call in the HTML output (see below). I > > thought that was the key to UJS in Rails3? > > > <form accept-charset="UTF-8" action="/course/ > > remove_student_from_course" data-remote="true" method="post"><div > > style="margin:0;padding:0;display:inline"><input name="utf8" > > type="hidden" value="✓" /><input name="authenticity_token" > > type="hidden" value="4uzcKHN73cndlQENeb7IWRhe6g0F5eFZG91y3ACWO0M=" /></ > > div> > > <input id="course_id" name="course_id" type="hidden" > > value="1529" /> > > <input id="student_id" name="student_id" type="hidden" > > value="437" /> > > <input class="submitLink" name="commit" type="submit" > > value="Remove" /> > > </form> > > > On Dec 16, 1:34 am, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Do you have anything pertinent/related/involved in the application.js > > > file? Try pulling that out as you could be having a failure in JS > > > that''s causing grief. Also -- check your console in Firebug (or > > > whatever you''re using) and see if errors are being thrown when the > > > page loads. > > > > On Dec 16, 1:19 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Yep, i''ve done that, too. Here''s the header of the ''rails.js'' version > > > > i''m using > > > > > /* > > > > * jquery-ujs > > > > * > > > > *http://github.com/rails/jquery-ujs/blob/master/src/rails.js > > > > * > > > > * This rails.js file supports jQuery 1.4.3 and 1.4.4 . > > > > * > > > > */ > > > > > On Dec 15, 11:08 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > > > > wrote: > > > > > > On Dec 16, 2010, at 12:48 AM, loominator1970 wrote: > > > > > > > Yes I am, here''s what I have in the application.html.erb view, and > > > > > > they are all in my javascript folder > > > > > > > <%= javascript_include_tag ''jquery-1.4.3.js'', ''rails'', ''application'' > > > > > > %> > > > > > > Ah, but have you replaced rails.js with the jquery version? > > > > > > curl -Ohttps://github.com/rails/jquery-ujs/raw/master/src/rails.js > > > > > > see the README athttp://github.com/rails/jquery-ujsformoredetails. > > > > > > -Rob > > > > > > > On Dec 15, 10:30 pm, Ray Parker <rayparkerbasspla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > >> Are you including rails.js? > > > > > > >> On Dec 16, 12:16 am, loominator1970 <loominator1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > >>> This seems like it should be pretty straightforward, but its > > > > > >>> stumping > > > > > >>> me. I have a small form that I am trying to submit using jquery > > > > > >>> that > > > > > >>> is supposed to remove an association between to HABTM models. For > > > > > >>> the > > > > > >>> sake of argument, the models are Course and Student. > > > > > > >>> # view > > > > > >>> <%= form_tag ( remove_student_from_course_path, :remote => > > > > > >>> true ) > > > > > >>> %> > > > > > >>> <%= hidden_field_tag "course_id", @course.id %> > > > > > >>> <%= hidden_field_tag "student_id", @student.id %> > > > > > >>> <%= submit_tag ''Remove'' %> > > > > > > >>> # controller > > > > > >>> def remove_student_from_class > > > > > >>> @student = Student.find(params[:student_id]) > > > > > >>> @msg = Factor.method_to_remove_student_from_class(params) > > > > > > >>> respond_to do |format| > > > > > >>> format.html { redirect_to edit_class_path(@class) } > > > > > >>> format.js > > > > > >>> end > > > > > >>> end > > > > > > >>> # remove_student_from_class.js.erb > > > > > >>> // reload the page > > > > > >>> location.reload(); > > > > > > >>> Everything works fine, except the HTML code is generated and not the > > > > > >>> JS code in the respond_to block. I would expect the JS call to get > > > > > >>> fired since I have the '':remote => true'' line in there, but its > > > > > >>> always > > > > > >>> the HTML and it generates the page. What am I overlooking? > > > > > > >>> Dave > > > > > > Rob Biedenharn > > > > > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ > > > > > r...-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/-- 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 16 December 2010 05:16, loominator1970 <loominator1970-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This seems like it should be pretty straightforward, but its stumping > me. I have a small form that I am trying to submit using jquery that > is supposed to remove an association between to HABTM models. For the > sake of argument, the models are Course and Student. > > # view > <%= form_tag ( remove_student_from_course_path, :remote => true ) > %> > <%= hidden_field_tag "course_id", @course.id %> > <%= hidden_field_tag "student_id", @student.id %> > <%= submit_tag ''Remove'' %> > > # controller > def remove_student_from_class > @student = Student.find(params[:student_id]) > @msg = Factor.method_to_remove_student_from_class(params) > > respond_to do |format| > format.html { redirect_to edit_class_path(@class) } > format.js > end > end > > # remove_student_from_class.js.erb > // reload the page > location.reload(); > > > Everything works fine, except the HTML code is generated and not the > JS code in the respond_to block. I would expect the JS call to get > fired since I have the '':remote => true'' line in there, but its always > the HTML and it generates the page. What am I overlooking?Show is what is in the log when you do the submit. 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The problem appears to be the dataType of the Ajax request -- it is requesting an HTML response rather than a script. I wonder if the default has changed recently? Anyway, calling $.ajaxSetup({ dataType: ''script'' }); at the top of your application.js or similar will change the default and appears to restore the expected behaviour. You could also set the data-type="script" attribute on your <form> or <a> tags. -- Posted via http://www.ruby-forum.com/. -- 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.
I''m having exactly the same issues as the original poster, and have checked all the settings mentioned above, and it''s still not working. I tried adding the $.ajaxSetup({ dataType: ''script'' }); to my application.js, and data-type="script" to my form, and it didn''t help. Any other ideas? Thanks... -- Posted via http://www.ruby-forum.com/. -- 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.
I found the answer (at least for me)! The issue is described here: https://github.com/rails/jquery-ujs/issues/issue/52 More info here on the official fix: https://github.com/rails/jquery-ujs/commit/fbbefa0773d791d3a67b7a3bb971c10ca750131b The solution was to add a line of jQuery to set the proper request header to handle Ajax calls. In my app/views/layouts/application.html.erb, just add this after you include the jQuery file: <script type="text/javascript"> jQuery.ajaxSetup({ beforeSend: function (xhr) { xhr.setRequestHeader("Accept", "text/javascript"); } }); </script> -- Posted via http://www.ruby-forum.com/. -- 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 Tue, Jan 4, 2011 at 6:04 PM, Noah H. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m having exactly the same issues as the original poster, and have > checked all the settings mentioned above, and it''s still not working. > > I tried adding the $.ajaxSetup({ dataType: ''script'' }); to my > application.js, and data-type="script" to my form, and it didn''t help. > > Any other ideas? Thanks...Are you using rails.js? https://github.com/rails/jquery-ujs/blob/v1.4/src/rails.js -- Greg Donald destiney.com | gregdonald.com -- 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.