我就是想在extjs的tree的拖拽成功之前加上事件监听,实现在拖拽的时候有提示,等用户确认后 实现拖拽用户取消则不拖拽。
我使用 tree.on('beforenodedrop',function(dropEvent){
//dropEvent.dropStatus=true;
Ext.log(dropEvent.target);
Ext.Msg.confirm('确认',"请确认是否要把菜单移动!",function(button){ if(button=='yes'){
dropEvent.cancel=false;
}else if(button=='no'){
dropEvent.cancel=true;
}
}
);
但是在没有确认的时候tree的拖拽已经完成。 不知道各位大侠有什么好的方法
我使用 tree.on('beforenodedrop',function(dropEvent){
//dropEvent.dropStatus=true;
Ext.log(dropEvent.target);
Ext.Msg.confirm('确认',"请确认是否要把菜单移动!",function(button){ if(button=='yes'){
dropEvent.cancel=false;
}else if(button=='no'){
dropEvent.cancel=true;
}
}
);
但是在没有确认的时候tree的拖拽已经完成。 不知道各位大侠有什么好的方法
tree.on('beforenodedrop',function(dropEvent){
dropEvent.preventDefault = true;
dropEvent.stopPropagation = true;
Ext.log(dropEvent.target);
Ext.Msg.confirm('确认',"请确认是否要把菜单移动!",function(button){ if(button=='yes'){
dropEvent.cancel=false;
}else if(button=='no'){
dropEvent.cancel=true;
}
}
);试试看
tree.on('beforenodedrop', function(e) {
var n = e.dropNode;
var t = e.target;
Ext.Msg.confirm('确认', "请确认是否要把菜单移动!", function(button) {
if (button == 'yes') {t.appendChild(n);}
});
return false;
});
click 时记录原始位置,
drop 时如果取消,则恢复原始位置;否则
var n = e.dropNode;
var t = e.target;
Ext.Msg.confirm('确认', "请确认是否要把菜单移动!", function(button) {
if (button == 'yes') {t.appendChild(n);}
});
return false;
});