Optimize logic for first value and button all selection

This commit is contained in:
guerler
2016-07-14 11:00:19 -04:00
parent f239a0a927
commit 0372bdb4ad
6 changed files with 11 additions and 10 deletions
@@ -172,12 +172,13 @@ var View = Backbone.View.extend({
/** Synchronizes the model value with the actually selected field value */
_changeValue: function() {
this._setValue( this.model.get( 'value' ) );
if ( this.model.get( 'searchable' ) ) {
if ( this._getValue() === null && !this.model.get( 'multiple' ) && !this.model.get( 'optional' ) ) {
this._setValue( this.first() );
if ( this.model.get( 'multiple' ) ) {
if ( this.all_button ) {
var value = this._getValue();
this.all_button.value( $.isArray( value ) ? value.length : 0, this.length() );
}
var value = this._getValue();
this.all_button && this.all_button.value( $.isArray( value ) ? value.length : 0, this.length() );
} else if ( this._getValue() === null && !this.model.get( 'optional' ) ) {
this._setValue( this.first() );
}
},
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long