|
1 | | -/* |
| 1 | +/* |
2 | 2 | Copyright 2012 Igor Vaynberg |
3 | 3 |
|
4 | 4 | Version: @@ver@@ Timestamp: @@timestamp@@ |
|
1016 | 1016 | */ |
1017 | 1017 | // abstract |
1018 | 1018 | updateResults: function (initial) { |
1019 | | - var search = this.search, results = this.results, opts = this.opts, self=this; |
| 1019 | + var search = this.search, results = this.results, opts = this.opts, data, self=this; |
1020 | 1020 |
|
1021 | 1021 | // if the search is currently hidden we do not alter the results |
1022 | 1022 | if (initial !== true && (this.showSearchInput === false || !this.opened())) { |
|
1035 | 1035 | results.html(escapeMarkup(html)); |
1036 | 1036 | postRender(); |
1037 | 1037 | } |
1038 | | - |
1039 | | - if (opts.selectionLimit && ("getVal" in this) && this.getVal().length >= opts.selectionLimit) { |
1040 | | - render("<li class='select2-selection-limit'>" + opts.formatLimitReached(opts.selectionLimit) + "</li>"); |
1041 | | - return; |
| 1038 | + |
| 1039 | + if (opts.maximumSelectionSize >=1) { |
| 1040 | + data = this.data(); |
| 1041 | + if ($.isArray(data) && data.length >= opts.maximumSelectionSize) { |
| 1042 | + render("<li class='select2-selection-limit'>" + opts.formatSelectionTooBig(opts.maximumSelectionSize) + "</li>"); |
| 1043 | + return; |
| 1044 | + } |
1042 | 1045 | } |
1043 | 1046 |
|
1044 | 1047 | if (search.val().length < opts.minimumInputLength) { |
|
2143 | 2146 | }, |
2144 | 2147 | formatNoMatches: function () { return "No matches found"; }, |
2145 | 2148 | formatInputTooShort: function (input, min) { return "Please enter " + (min - input.length) + " more characters"; }, |
2146 | | - formatLimitReached: function (limit) { return "You can only select " + limit + " items"; }, |
| 2149 | + formatSelectionTooBig: function (limit) { return "You can only select " + limit + " items"; }, |
2147 | 2150 | formatLoadMore: function (pageNumber) { return "Loading more results..."; }, |
2148 | 2151 | minimumResultsForSearch: 0, |
2149 | 2152 | minimumInputLength: 0, |
2150 | | - selectionLimit: 0, |
| 2153 | + maximumSelectionSize: 0, |
2151 | 2154 | id: function (e) { return e.id; }, |
2152 | 2155 | matcher: function(term, text) { |
2153 | 2156 | return text.toUpperCase().indexOf(term.toUpperCase()) >= 0; |
|
0 commit comments