Joh*_*mas 6 javascript jquery backbone.js marionette
有什么方法我可以从选择中删除一个项目
当我通过NA时,它应该删除特定项目
$.fn.removeSelectorValue = function (value) {
var selectize = this[0].selectize;
selectize.removeItem(value)
return this;
};
Run Code Online (Sandbox Code Playgroud)
这是行不通的..任何人都可以帮助我吗?
$(document).on('click', 'div.selectize-input div.item', function(e) {
var select = $('#services').selectize();
var selectSizeControl = select[0].selectize;
// 1. Get the value
var selectedValue = $(this).attr("data-value");
// 2. Remove the option
select[0].selectize.removeItem(selectedValue);
select[0].selectize.refreshItems();
select[0].selectize.refreshOptions();
});
Run Code Online (Sandbox Code Playgroud)
此代码不会从选择中删除该项目,只是将其从选定的选项中删除。
小智 6
removeItem删除由给定值标识的选定项目.要从列表中删除选项,您应该使用removeOption
示例 - 打开http://brianreavis.github.io/selectize.js/,打开控制台并输入:
$('#select-beast')[0].selectize.removeOption(1)
Run Code Online (Sandbox Code Playgroud)
从可用选项中删除Chuck Tesla
| 归档时间: |
|
| 查看次数: |
15799 次 |
| 最近记录: |