简体   繁体   中英

jquery draggable over function

i just want the OVER function block gets called after 4-5 seconds wen i hold the draged item for some seconds then the OVER function block need to b called else not

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

You'll probably want to use some sort of timeout:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM