jquery - Select2 allowClear click -
is there way run code clicking x remove contents of selected select2?
i've looked @ documentation not got me clear if there way this, need reset variables clicking x.
that's code
$("#cliente").select2({ multiple: false, allowclear: true, placeholder: "digite o nome", minimuminputlength: 3, ajax: { url: "endpoints/autocompletepaciente.php", datatype: 'json', data: function (term, page) { return { keyword: term }; }, results: function (data, page) { (var = 0; < data.length; i++) { data[i].id = data[i].cod; //data[i].value = data[i].nome; } return { results: data }; }, }, createsearchchoice: function(term) { return { id: term, nome: term, documento: ''}; }, formatresult: subjectformatresult, formatselection: subjectformatselection, escapemarkup: function (m) { return m; } }).on("unselecting", function(e) { console.log("sdsdd") })
if using jquery use following.
$(".select2-search-choice-close").on( "click", function() { // code here }); 
Comments
Post a Comment