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.

enter image description here

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

Popular posts from this blog

Angularjs unit testing - ng-disabled not working when adding text to textarea -

sql - invalid in the select list because it is not contained in either an aggregate function -

How to start daemon on android by adb -