早安,输入选择2删除选定
我:
$(document).ready(function() {
$('select[id$="cbxLocal"]').select2({ placeholder: 'Selecione primeiro uma solicitação', allowClear: true });
$('#cbxLocal').select2({
ajax: {
url: "../Servico/Local.ashx",
dataType: 'json',
type: 'GET',
data: function (term, page) {
return {
q: term,
idTipoLocal: idTipoLocal,
trazerEndereco: 1
};
},
results: function (bond, page) {
return {
results: bond.results
};
}
},
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
minimumInputLength: 3,
//templateResult: formatRepo, // omitted for brevity, see the source of this page
//templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
});
});
function limparTodosCampos() {
$('select[id$="cbxLocal"]').select2({ placeholder: 'Selecione', allowClear: false, data: null });
}
<label id="divCbxLocal" class="cbxLocal">
<span>Local</span>
<input id="cbxLocal" name="cbxLocal" class="select2" type="text" />
</label>
<fieldset>
<input id="btLimpar" type="button" value="Clear" onclick="limparTodosCampos()" />
</fieldset>
而且我想重置由JavaScript选择的值。 当我点击“清除”按钮时,我想清除用户在组合框中选择的值(select2) 我该怎么办?版本select2是2.
谢谢。
包括你的jQuery/JavaScript。 – Pugazh