I am trying to configure select2 plugin. It is working fine at the moment but when i try to disable case sensitivity then i am not able to figure it out.
Below are the codes.
<script type="text/javascript">
var lastResults = [];
$("#tags").select2({
multiple: true,
tags: true,
placeholder: "Please enter keywords",
tokenSeparators: [',', ' '],//[","],
initSelection : function (element, callback) {
var data = [];
$(element.val().split(",")).each(function () {
data.push({id: this, text: this});
});
callback(data);
},
ajax: {
multiple: true,
url: "fetch_keywords.php",
dataType: 'json',
data: function(term,page) {
return {
term: term
};
},
results: function(data,page) {
lastResults = data;
return {results: data};
},
},
maximumSelectionSize: 3,
minimumInputLength: 3,
maximumInputLength: 30,
createSearchChoice: function(term) {
var text = term + (lastResults.some(function(r) {
return r.text == term
}) ? "" : " (new)");
return {
id: term,
text: text
};
},
});
I have checked this question select2: Disable case-sensitive matches but i am not sure how can i use the same in my code.
If user entered test then it will return the match from database but if user enter Test then it create a new tag.
Thanks