mercredi 24 mars 2021

select2 js empty value on load in select option

I have implemented select2js in my project, In few cases when i load my page, an empty value is appending to my select input box. Can anyone help me out, what is the issue, I have added a image of it and My code is

{!! Form::select('searchSkillTools[]',[],(isset($skillToolXref) && $skillToolXref!='')?$skillToolXref:'', array('autocomplete' => 'off', 'class' => 'chosen-select','multiple'=>'multiple', 'id' => 'searchSkillTools-'.$randomId, 'placeholder' => '' ,'style' => 'height: auto !important')) !!}

$('#searchSkillTools-').select2({  
    ajax: {
        url: skillToolUrl,
        dataType: 'json',
        method:'get',
        delay: 250,//delay in response
        data: function (data) {
            return {
                search: data.term //search term
            };
        },
        /*option to transform the data returned by response into the format expected by Select2*/
        processResults: function (response) {            
            return {
                results:response
            };
        },
        cache: true
    }
});

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire