0
İyi günler,select2 sonucunu yeniden oluşturma
Projem için Select2 eklentisini kullanıyorum. Alıcı metninde e-posta işlevinde kullandım. İlk önce kullanıcı veritabanından alacağı bir şey yazdığında, o zaman select
benim için yeni seçenekler ekleyecektir. Benim sorunum, sonuçtan ziyade select2 sonucunu nasıl yeniden oluşturabilirim.
Aşağıda benim html kodu
<div class="form-group" id="div_select2">
<select class="form-control select2" id="select2_email" multiple="multiple" data-placeholder="Select a Group" style="width: 100%;">
<option></option>
<option value="group" data-id="1">Pulse Asia Group</option>
<option value="group" data-id="2">Unite Group</option>
<option value="group" data-id="3">RCBC Group</option>
</select>
</div><!-- /.form-group -->
Ve Select2 ajax seçeneği kullanılır
$(document).ready(function(){
$('#div_select2').on('keyup','.select2-search__field',function(){
keyme = $(this);
$(this).attr('added','current');
console.log($('#select2-select2_email-results li').eq(0));
if(typeof $('#select2-select2_email-results li').eq(0).attr('id') == 'undefined'){ //select2 no result
l = '<option class="added-opt" value="group" data-id="">'+$(this).val()+'</option>';
$('#select2_email').append(l);
//i want to trigger the repopulate of results here so the user can choose dynamic results
}
});
});