Attach the ajaxStop handler *after* making ajax requests in fn()
Also now broken out into separate setupAjaxStopHandler() function.
This commit is contained in:
parent
5e760a5266
commit
13062c108a
@ -1143,11 +1143,17 @@
|
|||||||
.text( $submitBtn.data( 'running' ) )
|
.text( $submitBtn.data( 'running' ) )
|
||||||
.addClass( 'disabled' )
|
.addClass( 'disabled' )
|
||||||
.off( 'click' );
|
.off( 'click' );
|
||||||
|
}
|
||||||
|
|
||||||
// And finally, make it so when all AJAX requests are
|
/**
|
||||||
// complete, the done text and a reload link will be shown
|
* Sets up the `ajaxStop` handler which runs after all ajax
|
||||||
|
* requests are complete and changes the text of the button
|
||||||
|
* to "Done" and auto-reloads the page.
|
||||||
|
*/
|
||||||
|
function setupAjaxStopHandler () {
|
||||||
$( document ).ajaxStop( function () {
|
$( document ).ajaxStop( function () {
|
||||||
$submitBtn.text( 'Done' )
|
$afch.find( '#afchSubmitForm' )
|
||||||
|
.text( 'Done' )
|
||||||
.append(
|
.append(
|
||||||
' ',
|
' ',
|
||||||
$( '<a>' )
|
$( '<a>' )
|
||||||
@ -1228,6 +1234,10 @@
|
|||||||
|
|
||||||
// Now finally call the applicable handler
|
// Now finally call the applicable handler
|
||||||
fn( data );
|
fn( data );
|
||||||
|
|
||||||
|
// After starting AJAX requests in the above function, set up the
|
||||||
|
// ajaxStop event handler which is trigger after they finish.
|
||||||
|
setupAjaxStopHandler();
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user