pom...@gmail.com
unread,Jan 9, 2015, 11:20:20 AM1/9/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sel...@googlegroups.com
Hello.
I've got three select2 on my page, two work very well, the third (the only that gets data from an ajax source) does not fire the change event.
the code is taken very closely from the repository search example.
The data is retrieved and shown correctly, but the change event is never fired. I feel like I've done a stupid error and that I can't see. Can anyone spot it?
thanks in advance,
m.
$("#cboClienti").select2({
placeholder: "search for a customer",
minimumInputLength: 1,
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
url: "/api/clienti/",
dataType: 'json',
quietMillis: 250,
data: function (term, page) {
return {
id: term, // search term
};
},
results: function (data, page) {
return { results: data};
},
cache: true
} ,
formatResult: clientiFormatResult,
formatSelection: clientiFormatSelection,
dropdownCssClass: "bigdrop",
escapeMarkup: function (m) { return m; }
})
.on("change",
function (e) {
$("#txtRSCliente").val(e.RagioneSociale);
});
});
function clientiFormatResult(cliente) {
var markup = '<div class="row-fluid">' +
'<div class="span2"> ' +
'<div class="span10">' +
'<div class="row-fluid">' +
'<div class="span6">nome: ' + cliente.NomeCompleto + '</div>' +
'<div class="span3">indirizzo: ' + cliente.IndirizzoCompleto + '</div>' +
'</div>';
markup += '</div></div>';
return markup;
}
function clientiFormatSelection(cliente) {
return cliente.NomeCompleto;
}