Last active
August 29, 2015 14:03
-
-
Save zacksleo/785bffb0540825b3a715 to your computer and use it in GitHub Desktop.
jeasyui combotree中,Ajax异步加载时,使用缓存,可以让其他字段共用该数据
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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