<input type="hidden" id="title" value="$!{map.dto.title}" name="title"/> // 隐藏

$('#title').select2({
placeholder: "销方名称",
minimumInputLength: 2,
maximumInputLength: 50,
allowClear: true,
width: '100%',
ajax: {
url: "$basePath/notget/list_title.htm",
type: 'get',
data: function (params) {
return { 'keyword': params };
},
results: function (result) { // 结果格式要遵循 [{id: '', text: ''}]
return {'results': JSON.parse(JSON.stringify(result.data))}
},
},
createSearchChoice: function (term, data) { // 创建搜索结果(使用户可以输入匹配值以外的其它值)
$("#title").val(term)
},
initSelection: function (element, callback) { // 初始选中
var text = $("#title").val()
callback({id: text, text: text}); // 回调formatSelection
},
formatSelection: function(item) { // 选中项
return item.text;
},
formatResult: function format(item) {
return item.text; // 选中时,显示的值
},
dropdownCssClass: "bigdrop" //样式
});
posted on 2020-10-22 18:51  yang希军  阅读(628)  评论(0)    收藏  举报