KevinC
2012-Mar-07 03:59 UTC
link_to with :remote=>true works when bound to "click" but not "ajax:beforeSend"
Hi. I am trying to do an ajax link in Rails 3.2.1 and jQuery. I am
loading jquery.js and jquery_ujs.js. In my document ready, if I bind
to the event "click," clicking the link fires an event, but if I click
to ajax:beforeSend, it doesn''t. Nothing happens when you click the
link in JQuery. The event does go to the controller, though.
Works:
$(document).ready(function(){
$(''.approve-item'').bind("click", function(evt,
xhr, settings){
alert(''click'');
})
});
Doesn''t Work:
$(document).ready(function(){
$(''.approve-item'').bind("ajax:beforeSend",
function(evt, xhr,
settings){
alert(''before send'');
})
});
Any ideas on how to trouble shoot this? I''ve spent hours on this and
can''t find a good reason why this isn''t working.
No errors in the Chrome console, for what it''s worth.
Thanks for any help,
Kevin
--
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.
Paul
2012-Mar-13 13:50 UTC
Re: link_to with :remote=>true works when bound to "click" but not "ajax:beforeSend"
$(''approve-item'').bind(''ajax:before'',
function( etc...
On Tue, Mar 6, 2012 at 10:59 PM, KevinC
<kevinchugh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi. I am trying to do an ajax link in Rails 3.2.1 and jQuery. I am
> loading jquery.js and jquery_ujs.js. In my document ready, if I bind
> to the event "click," clicking the link fires an event, but if I
click
> to ajax:beforeSend, it doesn''t. Nothing happens when you click
the
> link in JQuery. The event does go to the controller, though.
>
> Works:
>
> $(document).ready(function(){
> $(''.approve-item'').bind("click",
function(evt, xhr, settings){
> alert(''click'');
> })
> });
>
> Doesn''t Work:
>
> $(document).ready(function(){
> $(''.approve-item'').bind("ajax:beforeSend",
function(evt, xhr,
> settings){
> alert(''before send'');
> })
> });
>
> Any ideas on how to trouble shoot this? I''ve spent hours on this
and
> can''t find a good reason why this isn''t working.
>
> No errors in the Chrome console, for what it''s worth.
>
> Thanks for any help,
> Kevin
--
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.