选择设置值可以删除

时间:2017-03-16 23:29:40

标签: yii2 select2

我使用kartik select2小部件来显示Select2插件。

当init select并且它正在运行时,我需要通过将PlaceHolder设置为select

来设置select 2的值

示例:

$('#select_ID').val(null).trigger("change");
$("#select2-select_ID-container .select2-selection__placeholder").text(cName);

因此,清除功能不活跃。 喜欢Image就可以。

enter image description here

那不行。因为,清除图标不显示。

enter image description here 我该怎么做?并在初始值时显示清除按钮。

1 个答案:

答案 0 :(得分:0)

占位符是静态的,您不应该清除它。选择值后,应显示清除操作。