Skip to content

Instantly share code, notes, and snippets.

@zacksleo
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save zacksleo/785bffb0540825b3a715 to your computer and use it in GitHub Desktop.

Select an option

Save zacksleo/785bffb0540825b3a715 to your computer and use it in GitHub Desktop.
jeasyui combotree中,Ajax异步加载时,使用缓存,可以让其他字段共用该数据
/**
* jeasyui combotree中,Ajax异步加载时,使用缓存,可以让其他字段共用该数据
* todo: 没有成功
*/
$('#city_id').combotree({
textField: 'name',
valueField: 'id',
multiple: false,
onBeforeLoad: function(param){
console.log('onBeforeLoad');
var selected = $('#city_id').combotree('tree').tree('getChecked');
console.log(selected);
if(selected){
var children = selected.hasOwnProperty('children') ? $('#city_id').combotree('tree').tree('getChildren', selected.target) : false;
}
console.log(children);
if(children && children.length > 0){
console.log('false');
return false;
}
$.post(ROOT + 'Home/Area/getComboTree', {
id: param ? param : 0
}, function(data){
var data = eval("(" + data + ")");
if(data){
if(!selected){
$('#city_id').combotree('tree').tree('loadData', data);
}else{
$('#city_id').combotree('tree').tree('append', {
parent: selected.target,
data: data
});
}
}
});
return false;
},
onLoadSuccess: function(){
}
}).next().find('.validatebox-text').attr('placeholder', '请选择出发城市');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment