gpt4 book ai didi

javascript - Select2 占位符问题

转载 作者:行者123 更新时间:2023-12-05 01:17:35 24 4
gpt4 key购买 nike

我有一个 Select2 Multiselect html 元素。渲染占位符时未显示,但如果我选择并删除该项目,则显示占位符。我不知道如何使它工作。请指教。

最初

enter image description here

选择时

enter image description here

移除项目后

enter image description here

enter image description here

代码:

@Html.DropDownListFor(m => m.Vendor, new SelectList(Model.Status), "Search Status", new { @id = "advanced-search-lsc-status", @class = "form-control", @multiple = "multiple", data_placeholder = "Select Status" })


$('#advanced-search-status').select2({
minimumResultsForSearch: -1,
placeholder: function(){
$(this).data('placeholder');
},
width: '100%'
});

最佳答案

刚刚发现是哪里出了问题,最初宽度设置为 0 隐藏了占位符。

enter image description here

刚刚使用此 jquery 代码进行操作。

.select2-container--default .select2-search--inline .select2-search__field{
width:initial!important;
}

现在可以了

enter image description here

谢谢大家。

关于javascript - Select2 占位符问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49648571/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com