Start/Stop Submission

The form submission process can be halted by replying to the maybe:submit request on a form specific radio channel (TODO: Add link to Radio docs). The return value (boolean) of the callback will determine if the form continues to submit.

Setting form “extra data” can be used as a flag to conditionally halt a submission. This can be very useful for an asyn callback that re-starts the form submission process.

var myCustomController = Marionette.Object.extend({
initialize: function() {
// … 'form-' + formID ).reply( 'maybe:submit', this.beforeSubmit, this, formID );
beforeSubmit: function( formID ) {
var formModel = 'app' ).request( 'get:form', formID );
if( formModel.getExtra( 'my_restart_flag' ) ) return true;
this.otherProcessing( formModel );
// Halt form submission.
return false;
otherProcessing: function( formModel ) {
// Set re-start flag 'form-' + this.formModel.get( 'id' ) ).request( 'add:extra', 'my_restart_flag', true );
// Re-start submission. 'form-' + formModel.get( 'id' ) ).request( 'submit', formModel );
jQuery( document ).ready( function( $ ) {
new myCustomController();

view raw
hosted with ❤ by GitHub