Extra error handling

This commit is contained in:
Mike Jolley 2016-03-31 15:18:35 +01:00
parent 687d4be0bf
commit 34b65e339a
2 changed files with 13 additions and 7 deletions

View File

@ -276,12 +276,7 @@
// If there were errors, prepend the form.
if ( response.data.errors.length > 0 ) {
var error_html = '<div id="woocommerce_errors" class="error notice is-dismissible">';
$( response.data.errors ).each( function( index, value ) {
error_html = error_html + '<p>' + value + '</p>';
} );
error_html = error_html + '</div>';
$( 'table.wc-shipping-zone-methods' ).before( error_html );
this.showErrors( response.data.errors );
}
// Method was saved. Re-render.
@ -291,10 +286,21 @@
shippingMethodView.model.onSaveResponse( response, textStatus );
}
} else {
window.alert( data.strings.save_failed );
shippingMethodView.unblock();
}
}, 'json' );
}
},
showErrors: function( errors ) {
var error_html = '<div id="woocommerce_errors" class="error notice is-dismissible">';
$( errors ).each( function( index, value ) {
error_html = error_html + '<p>' + value + '</p>';
} );
error_html = error_html + '</div>';
$( 'table.wc-shipping-zone-methods' ).before( error_html );
}
} ),
shippingMethod = new ShippingMethod({

File diff suppressed because one or more lines are too long