jquery draggable over function

时间:2012-11-28 06:26:08

标签: javascript jquery-ui jquery jquery-plugins

我只想在4-5秒后调用OVER功能块  我保持拖动项目几秒钟然后OVER功能块需要调用否则

$('.treeLink').droppable({
    tolerance: 'pointer',
    accept: '.childLinks',
    over: function() {},
    over: function() {
        getTreeLinks($(this).attr('id').split("treeLink")[1]);
    },
    drop: function() {
        updateGovLinks($(this).attr('id'));
    }
});

1 个答案:

答案 0 :(得分:1)

你可能想要使用某种超时:

var timeout;
$('.treeLink').droppable({
    tolerance: 'pointer',
    accept: '.childLinks',
    over: function() {
        var self = this;
        timeout = setTimeout(function () {
             getTreeLinks($(self).attr('id').split("treeLink")[1])
        }, 4000);
    },
    out: function () {
        clearTimeout(timeout);
    },
    drop: function() {
        updateGovLinks($(this).attr('id'));
    }
});