jqueryruby-on-railsruby-on-rails-3jquery-ujs

Rails UJS: Preventing the event from propagating using 'ajax:before'


I am confused by how ajax:before works when using rails/jquery-ujs.

  1. Does it wait for any given function in the ajax:before to complete before proceeding?

  2. How do I completely cancel the event in jQuery if it fails some condition? (I do not seem to have a pointer to the event)

--

Update: I tried this, which normally works, but not now. =|

.bind('ajax:before', function(evt){
    evt.stopImmediatePropagation();
   } )
 //also tried preventDefault, stopPropagation, etc

Solution

  • I answered my own question. "return false" in the ajax:before will cancel the action