gpt4 book ai didi

gwt-query - 嵌套可拖动传播

转载 作者:行者123 更新时间:2023-12-02 14:18:04 24 4
gpt4 key购买 nike

我编写了以下代码:

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);

当我开始拖动内部元素时,我的问题就开始了,然后draggable(childDraggable的父级)也开始拖动(仅在IE8中,我猜,在以前的版本中)。我想防止这种事件传播,即我想拖动innerElement而不拖动其父级。

我尝试过 stopPropagationpreventDefault 但效果不佳。如有帮助,将不胜感激。

提前致谢。

最佳答案

stopPropagation 在 IE 上不起作用,您应该按以下方式使用 cancelBubble 之类的东西:

function stop(e) {
// feature check (in IE this will be undefined)
if (e.stopPropagation) {
// standards compliant browser
e.stopPropagation();
} else {
// dreadful IE
e.cancelBubble = true;
}
}

关于gwt-query - 嵌套可拖动传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16950665/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com