tree.on('beforemovenode', function(t,node,oldParent,newParent,index) {
Ext.Ajax 提交数据到服务器处理,
判断 如果服务器处理失败 return false
});
因为Ajax为异步提交,如何才能在函数退出前,得到服务器返回状态,从而判断函数是否返回false,取消节点移动
需要的效果是 节点移动前 发送数据到服务器处理,如果处理成功那么执行移动,否则不移动,只要能得到这个效果不一定按上面的代码逻辑处理。
[b]问题补充:[/b]
atian25 ,yourgame 的方法是不行的 Ajax 是异步执行的,在判断函数中得不到返回值
atian25,的方法应该可行,正在测试中,tree 中怎么没有move方法,该怎么移动节点呢?
你这里没办法等待着返回false.
应该是在这里显示个loadmask,返回false,
然后在ajax事件后再调用对应的move方法.
要不就这里用ajax的同步执行,不过要重写下ext的ajax方法.
Ext.Ajax.request({
url: 'foo.php',
success: someFn,
failure: otherFn,
headers: {
'my-header': 'foo'
},
params: { foo: 'bar' }
});
在someFn和otherFn里面处理
[code="js"]tree.on('beforemovenode', function(t,node,oldParent,newParent,index) {
//Ext.Ajax 提交数据到服务器处理,
Ext.Ajax.requeset({
url:'d.jsp',
callback :function(option,success,response){
if(success){// 判断 如果服务器处理失败 return false
return true;
}
return false;
}
});
}); [/code]
就是把一个TreeNode appendChild到另一个TreeNode去