When I type "201" I want to send "201" to my ajax function and then search in my database, but when I click enter select2 gets 2010 - the first value from options list.
My configuration is:
$(".clear-results").select2({
placeholder: "Select a State",
allowClear: true,
width: 200,
matcher: function(term, text) {
return zext.trim().toUpperCase().indexOf(term.trim().toUpperCase())==0;
}
});
Regards,
Tsvetelin
in select2.js file:
I replaced :
case c.ENTER:return this.selectHighlighted
with
case c.ENTER:return get_input_value(this.search.val())
where get_input_value is my custom ajax function passing dynamically values.
case c.ENTER:return get_input_value(this.search.val())
to
case c.ENTER:return get_input_value(this.search.val())
case c.ENTER:return get_input_value(this.search.val(), this.containerId)
Added this.containerId, because select2 can have alot of selects, and we need to know which one send the value.