I’m trying to get a success/failure event when a form with :remote => true has been saved.
I’ve tried:
$( '#feedback-form' ).bind( 'ajaxSuccess', function( data, status, xhr ) {
alert( 'success' );
} )
But that fires on #feedback-form for all successful ajax events, even if they completely unrelated to the ajax save of the form.
I understand why (ajaxSuccess is not specific to the form but to ajax), but I can’t seem to find a :remote compatible equivalent to .submit() which fires when the ajax save is complete or has failed.
Is there a nice way to do this?
There are some specific binding from Jquery-ujs library. All is explain in documentation :
https://github.com/rails/jquery-ujs/wiki/ajax
So you can bind only the
ajax:successevent