使用Google托管的最新jQuery/UI。我有以下标记:jQuery拖放问题:mousemove事件没有绑定某些元素
<ul id="tree">
<li><a href="1/">One</a></li>
<li><a href="2/">Two</a></li>
</ul>
而且下面的JavaScript:
$(document).ready(function(){
// Droppable callbacks
function dragOver(overEvent, ui_object) {
$(this).mousemove(function(moveEvent){
console.log("moved over", this);
});
}
function drop_deactivate() {
$(this).unbind();
}
function drag_out() {
$(this).unbind();
}
// Actual dragging
$("#treeContainer li").draggable({
revert: true,
revertDuration: 0
});
// Actuall dropping
$("a").droppable({
tolerance: "pointer",
over: dragOver,
deactivate: drop_deactivate,
out: drag_out
});
});
如果我将第一个li
拖过第二个,mousemove函数会激发(并且firebug会记录输出)。但是,如果我将第二个li
拖过第一个,则mousemove函数不会触发。你可以在http://jsbin.com/ivala上看到。是否有一个原因?我应该以其他方式捕捉mousemove事件吗?
编辑:它看起来像mousemove()事件没有绑定的早期元素比当前正在拖动(应绑定到他们的鼠标悬停)。
我打开链接,有时将第二个li拖拽到第一个firebug上记录输出。但是,第一个过程比第一个过程更容易。 – 2009-08-19 18:58:05
我也注意到了。这不是regualr行为;非常令人费解。 – saturdayplace 2009-08-19 21:26:34
你想通过添加mousemove事件来完成什么? – PetersenDidIt 2009-08-22 15:20:45