2011-11-25 49 views
1

因为我可能有一个1000(或更多)DIVS,所有可以被拖放到另一个上,我发现把jquery .droppable放在所有的DIV上页面加载完成时间太长。因此,我试图使用mouseover函数将droppable仅添加到用户实际尝试放置某些内容的DIV。通过mouseover事件添加Jquery droppable没有看到OVER事件

这工作正常的下降:但作为预期过不采取行动:

下面是代码

$('.nc').mouseover(function() { 
    $(this).droppable({ 
     tolerance: 'touch', 

     over: function(event, ui) { // do this .. highlight the div being dropped on // }, 

     out: function(event, ui) { // do this .. unhighlight the div being dropped on // }, 

     drop: function(event, ui) { // do this .. handle the drop even // } 

    }); 
}); 

当我拖放到任意DIV与.NC类的一个片段,这个下降实际上工作正常。然而,当我将一个项目拖到DIV上时,“over”不起作用,除非我的鼠标在尝试拖动DIV之前已经过了DIV。

请注意,我知道我可以使用hoverClass来突出显示,但我需要在over事件中提供一些逻辑,以便它仅在特定条件下突出显示。

我一直在争取很久,所以希望有人能帮忙。谢谢。

回答

0

对于每个结束“}”被注释掉线

over: function(event, ui) { // do this .. highlight the div being dropped on // }, 

    out: function(event, ui) { // do this .. unhighlight the div being dropped on // }, 

    drop: function(event, ui) { // do this .. handle the drop even // } 

,因此它打破了功能

$('.nc').mouseover(function() { 
    $(this).droppable({ 
     tolerance: 'touch', 

     over: function(event, ui) { }, 

     out: function(event, ui) { }, 

     drop: function(event, ui) { } 

    }); 
}); 
+0

对不起,我的代码有},在每年年底。我只是忘了把它包含在我的伪代码中。感谢您的尝试。我的问题仍然存在。 –