我编写了以下代码:
HorizontalPanel draggable = new HorizontalPanel();
Function startDragParent = new Function () {
@Override
public boolean f (Event e) {
// some code here...
return false;
}
};
Function dragParent = new Function () {
@Override
public boolean f (Event e) {
// some code here...
return false;
}
};
Function stopDragParent = new Function () {
@Override
public boolean f (Event e) {
// some code here...
return false;
}
};
$(draggable).as(Ui).draggable()
.bind(Draggable.Event.start, startDragParent);
.bind(Draggable.Event.drag, dragParent);
.bind(Draggable.Event.stop, stopDragParent);
HorizontalPanel childDraggable = new HorizontalPanel();
Function dragChild = new Function () {
@Override
public boolean f (Event e) {
// some code here...
return false;
}
};
$(childDraggable).as(Ui).draggable().bind(Draggable.Event.drag, dragChild);
// finally I add one element inside another
draggable.add(childDraggable);
当我开始拖动内部元素时,我的问题就开始了,然后可拖动(childDraggable 的父级)也开始拖动(仅在 IE8 中,我猜在以前的版本中)。我想阻止这种事件传播,即我想拖动 innerElement 而不拖动其父级。
我已经尝试过stopPropagation和preventDefault但效果不佳。帮助将不胜感激。
提前致谢。