1
0
mirror of synced 2024-11-22 21:16:10 +03:00

fix closeOnSelect and maximumSelectionSize combo bug. fixes #672

This commit is contained in:
Igor Vaynberg 2013-02-09 15:48:20 -08:00
parent 6c4b96791d
commit d54378563c

View File

@ -1158,6 +1158,11 @@ the specific language governing permissions and limitations under the Apache Lic
},
//abstract
getMaximumSelectionSize: function() {
return evaluate(this.opts.maximumSelectionSize);
},
// abstract
ensureHighlightVisible: function () {
var results = this.results, children, index, child, hb, rb, y, more;
@ -1339,7 +1344,7 @@ the specific language governing permissions and limitations under the Apache Lic
postRender();
}
var maxSelSize = $.isFunction(opts.maximumSelectionSize) ? opts.maximumSelectionSize() : opts.maximumSelectionSize;
var maxSelSize = this.getMaximumSelectionSize();
if (maxSelSize >=1) {
data = this.data();
if ($.isArray(data) && data.length >= maxSelSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) {
@ -2222,6 +2227,7 @@ the specific language governing permissions and limitations under the Apache Lic
// multi
onSelect: function (data, options) {
this.addSelectedChoice(data);
if (this.select || !this.opts.closeOnSelect) this.postprocessResults();
if (this.opts.closeOnSelect) {
@ -2231,10 +2237,16 @@ the specific language governing permissions and limitations under the Apache Lic
if (this.countSelectableResults()>0) {
this.search.width(10);
this.resizeSearch();
if (this.val().length >= this.getMaximumSelectionSize()) {
// if we reached max selection size repaint the results so choices
// are replaced with the max selection reached message
this.updateResults(true);
}
this.positionDropdown();
} else {
// if nothing left to select close
this.close();
this.search.width(10);
}
}