select2tree
select2tree copied to clipboard
doesn't work well with ajax. (select2 v4.0.3)
`$("#sajaxtree").select2tree({
language : "zh-CN",
multiple : "multiple",
allowClear : true,
ajax : {
url : $webPath + 't.do?getFuncList',
dataType : 'json',
delay : 250,
data : function(params) {
var query = {
search : params.term,
page : params.page || 1,
rows : 30,
key : 'EXPERT_TEAM'
}
// Query paramters will be ?search=[term]&page=[page]
return query;
},
processResults : function(data, params) {
params.page = params.page || 1;
var rows = data.rows;
var newrows = [];
for ( var i in rows) {
var row = rows[i];
/* row.id = row.funcCode;
row.text = row.funcName;
row.parent = row.parentCode; */
newrows[i] = new Object();
newrows[i].id = row.funcCode;
newrows[i].text = row.funcName;
newrows[i].parent = row.parentCode;
}
console.debug("ajax返回的对象是:")
console.debug(newrows)
return {
results : newrows,
pagination : {
more : (params.page * 30) < data.total
}
};
},
cache : true
},
escapeMarkup : function(markup) {
return markup;
},
templateResult : formatTreeRepo,
templateSelection : formatRepoSelection
});`
getFuncList return a simple json string of bean array . it was display as a simple select2 object ,but not tree in droplist.
error on console: "jquery-1.8.3.min.js:2 Uncaught RangeError: Maximum call stack size exceeded(…)" nt @ jquery-1.8.3.min.js:2 find @ jquery-1.8.3.min.js:2 init @ jquery-1.8.3.min.js:2 v @ jquery-1.8.3.min.js:2 moveOption @ select2tree.js:33 (anonymous function) @ select2tree.js:35 each @ jquery-1.8.3.min.js:2 each @ jquery-1.8.3.min.js:2 moveOption @ select2tree.js:34 (anonymous function) @ select2tree.js:35 each @ jquery-1.8.3.min.js:2 each @ jquery-1.8.3.min.js:2 moveOption @ select2tree.js:34 (anonymous function) @ select2tree.js:35 each @ jquery-1.8.3.min.js:2 each @ jquery-1.8.3.min.js:2 moveOption @ select2tree.js:34 (anonymous function) @ select2tree.js:35 each @ jquery-1.8.3.min.js:2