-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configuring/overwriting minimumResultsForSearch via data attributes #3199
Comments
|
miquel-cabanas
added a commit
to miquel-cabanas/InvoicePlane
that referenced
this issue
Aug 12, 2018
needed: either when there is a short number of options, or options are hard coded (e.g. yes/no questions). See: https://stackoverflow.com/questions/17480040/select2-hiding-the-search-box (in particular, Aaron Hudon's answer) select2/select2#3199 select2/select2#3189
miquel-cabanas
added a commit
to miquel-cabanas/InvoicePlane
that referenced
this issue
Aug 12, 2018
needed: either when there is a short number of options, or options are hard coded (e.g. yes/no questions). See: https://stackoverflow.com/questions/17480040/select2-hiding-the-search-box (in particular, Aaron Hudon's answer) select2/select2#3199 select2/select2#3189
miquel-cabanas
added a commit
to miquel-cabanas/InvoicePlane
that referenced
this issue
Aug 12, 2018
needed: either when there is a short number of options, or options are hard coded (e.g. yes/no questions). See: https://stackoverflow.com/questions/17480040/select2-hiding-the-search-box (in particular, Aaron Hudon's answer) select2/select2#3199 select2/select2#3189
If somebody still wants to configure any option using
<select data-options="minimumResultsForSearch:Infinity; param: hehe; float : 45.34">...</select>
$("select").each(function (idx, select) {
var options = $(select).data("options");
if (options) {
options = options.split(/\s*;\s*/).reduce(function (a, c) {
c = c.split(/\s*:\s*/);
a[c[0]] = isNaN(c[1]) ? c[1] : (parseInt(c[1], 10) == c[1] ? parseInt(c[1], 10) : parseFloat(c[1]));
return a;
}, {});
$(select).select2(options);
} else {
$(select).select2();
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to configure (overwrite) the
minimumResultsForSearch
option via data-attributes, but this doesn't work:Also tried
data-minimumResultsForSearch
(camelCase and lowercase).Setting it via javascript works as aspected:
JSFiddle
It seem to be working in v4.0.0-rc.2 but I'm still using v3.5.2 (select2-rails isn't updated yet).
Is this a known issue? Is there a workaround?
The text was updated successfully, but these errors were encountered: