早安,輸入選擇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