单击其中的选项时,保持挖空选择菜单打开



如何防止选择菜单在单击内部时关闭,而在菜单外部单击时应自行关闭

enter code herehttps://jsfiddle.net/1jekvsb6/1/

我尝试使用此参考 https://knockoutjs.com/documentation/click-binding.html 其他人已经指出了,但我无法让这个工作......任何帮助非常感谢!

嗨约翰如果多选阻止关闭和外部单击简单删除项目 并在单击事件时添加项目。我只显示多项选择

var model = function() {
var self = this;
self.arr = ko.observableArray([
{ Type: "Item1" },
{ Type: "Item2" },
{ Type: "Item3" },
{ Type: "Item4" },
{ Type: "Item5" }
])
}
var theModel = new model();
ko.applyBindings(theModel, document.getElementById("container"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<div id="container">
<select multiple style="width: 150px;" size=5 data-bind="options: arr, optionsText: 'Type', optionsValue: 'Type', click: function() {}, clickBubble: false">
<option data-bind="click: function() {return false;}, clickBubble: true"></option>
</select>
</div>

最新更新