1
0
mirror of synced 2024-11-26 23:06:02 +03:00

Merge pull request #702 from skivvies/master

allow passing a function for maximumSelectionSize
This commit is contained in:
Igor Vaynberg 2013-02-05 15:05:57 -08:00
commit c90bfc3e22

View File

@ -1255,10 +1255,11 @@ the specific language governing permissions and limitations under the Apache Lic
postRender(); postRender();
} }
if (opts.maximumSelectionSize >=1) { var maxSelSize = $.isFunction(opts.maximumSelectionSize) ? opts.maximumSelectionSize() : opts.maximumSelectionSize;
if (maxSelSize >=1) {
data = this.data(); data = this.data();
if ($.isArray(data) && data.length >= opts.maximumSelectionSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) { if ($.isArray(data) && data.length >= maxSelSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) {
render("<li class='select2-selection-limit'>" + opts.formatSelectionTooBig(opts.maximumSelectionSize) + "</li>"); render("<li class='select2-selection-limit'>" + opts.formatSelectionTooBig(maxSelSize) + "</li>");
return; return;
} }
} }