Select2 issue
Select2 issue
I'm using Select2 to allow me to select two (and only two) items from a dropdown list. I've built the dropdown list, but it allows me to select more than two items.
The select2 website mentions the "maxSelectionLength" parameter, but in their code example, they use "maximumSelectionLength". I've tried it both ways. I've tried the "2" with and without quotes. I've tried putting the max option as an attribute. I've tried various combinations of the above. Nothing has given me the desired result. It just looks like this option is being ignored.
Any idea what I'm doing wrong?
Below is my code:
editor = new $.fn.dataTable.Editor( {
ajax: "/lte_sim/modems.php",
table: "#modems",
fields: [ {
label: "Store:",
name: "modems.store_id",
}, {
label: "SIMs:",
name: 'sims[].id',
type: "select2",
attr: {
multiple: "multiple"
},
opts: {
maximumSelectionLength: "2"
}
}, {
label: "Modem MEID:",
name: "modems.meid"
}, {
label: "Active Vendor:",
name: "modems.vendor_id",
type: "select2",
opts: {
minimumResultsForSearch: "Infinity"
}
}
]
} );
This question has an accepted answers - jump to answer
Answers
Found my issue. I was looking at the docs for version 4.0.0, which is what the Select2 website has moved to. In the 3.5.2 docs, this item is "maximumSelectionSize".
Should I be using 3.5.2, or is it safe to run 4.0.0 with Editor?
Good to hear you found the issue.
I haven't yet tried using Select2 4.0.0 with Editor yet. It looks like they have changed a number of things, so there might well be incompatibilities. I've added it to my list of plug-ins to look at!
Regards,
Allan
Any update on Select2 4.0.0 with Editor?
Not yet - sorry. Overwhelmed with the number of things to do at the moment, but this is still on the list. I'll probably get Editor 1.5 out of the door before this.
Allan
I've just tried Select2 4.0.0 (release) with the latest version of the Editor plug-in and it appears to just work out of the box. 4.0.0 will the version that the plug-in will refer to when I deploy Editor 1.5.
Allan