我正在使用Select2,我可以使用tags: true
创建动态选项,但是当我选择上一个选项时,新添加的选项已经消失。
如何将其保存到数据中,以便始终可见?
我添加了jsfiddle,但它并不漂亮,但确实证明了我的问题
var data = [{
id: 0,
text: '<div style="font-size: 1.2em; color:green">enhancement</div><div><b>Select2</b> supports custom themes using the theme option so you can style Select2 to match the rest of your application.</div>',
title: 'enchancement'
},
{
id: 1,
text: '<div style="color:red">bug</div><div><small>This is some small text on a new line</small></div>',
title: 'bug'
}];
$("#other").select2({
tags: true,
data: data,
escapeMarkup: function(markup) {
return markup;
},
createTag: function(params) {
var obj = {
id: 'new_' + params.term,
text: '<div style="font-size: 1.2em; color:blue">' + params.term + '</div><div><b>Select2</b> supports custom themes using the theme option so you can style Select2 to match the rest of your application.</div>',
title: params.term
};
return obj;
},
insertTag: function (data, tag) {
// Insert the tag at the end of the results
data.push(tag);
}
});
答案 0 :(得分:1)
您需要触发private void TB_LostFocus(object sender, EventArgs e)
{
}
功能
试试这个
select2:select