select2 js 在 select 选项中加载空值
select2 js empty value on load in select option
我在我的项目中实施了 select2js,在少数情况下,当我加载我的页面时,我的 select 输入框会附加一个空值。谁能帮帮我,这是什么问题,
我添加了它的图像,我的代码是
{!! Form::select('searchSkillTools[]',[],(isset($skillToolXref) && $skillToolXref!='')?$skillToolXref:'', array('autocomplete' => 'off', 'class' => 'chosen-select','multiple'=>'multiple', 'id' => 'searchSkillTools-'.$randomId, 'placeholder' => '' ,'style' => 'height: auto !important')) !!}
$('#searchSkillTools-{{$randomId}}').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
}
});
这种方式将修复错误:
(isset($skillToolXref) && $skillToolXref!='')?$skillToolXref:null
我在我的项目中实施了 select2js,在少数情况下,当我加载我的页面时,我的 select 输入框会附加一个空值。谁能帮帮我,这是什么问题, 我添加了它的图像,我的代码是
{!! Form::select('searchSkillTools[]',[],(isset($skillToolXref) && $skillToolXref!='')?$skillToolXref:'', array('autocomplete' => 'off', 'class' => 'chosen-select','multiple'=>'multiple', 'id' => 'searchSkillTools-'.$randomId, 'placeholder' => '' ,'style' => 'height: auto !important')) !!}
$('#searchSkillTools-{{$randomId}}').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
}
});
这种方式将修复错误:
(isset($skillToolXref) && $skillToolXref!='')?$skillToolXref:null