1

我只想在 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'));
    }
});
4

1 回答 1

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'));
    }
});
于 2012-11-28T06:37:18.300 回答