rails/jquery-ujs — pull request #364 by MoonScript (2014-03-04 22:00:55+00:00)
Title: disable-on-send

Don't fire the `ajax:send` event if an `ajax:beforeSend` event-handler cancels the AJAX request (via `return false`). Currently, it's lying to us because you would still see an `ajax:send` event even if no request was made. This will make it honest by only firing `ajax:send` if a request was actually heading to the server.

Don't disable form elements until the `ajax:send` event fires. Currently, it disables form elements when the `ajax:beforeSend` event bubbles up to the document. So if you had your own document-level `ajax:beforeSend` event-handler that was bound *after* the one from `jquery_ujs.js`, your form elements would still get disabled, even if you cancelled the AJAX request by doing `return false` from your event-handler. This will wait to disable the form elements until we're sure that an AJAX request is actually being made, by hooking into the `ajax:send` event.