Give the Model a setRateAttribute method.

This should simplify updating when listening for changes in the form.
This commit is contained in:
George Stephanis 2015-08-10 17:24:06 -04:00
parent 1332ef4a71
commit efcb9f5048
1 changed files with 10 additions and 1 deletions

View File

@ -17,7 +17,16 @@
$table = $( '.wc_tax_rates' ),
$tbody = $( '#rates' ),
$pagination = $( '#rates-pagination' ),
WCTaxTableModelConstructor = Backbone.Model.extend( {} ),
WCTaxTableModelConstructor = Backbone.Model.extend({
setRateAttribute : function( rateID, attribute, value ) {
var rates = this.get( 'rates' );
if ( rates[ rateID ][ attribute ] !== value ) {
rates[ rateID ][ attribute ] = value;
this.set( 'rates', rates );
}
}
} ),
WCTaxTableViewConstructor = Backbone.View.extend({
rowTemplate : rowTemplate,
per_page : data.limit,