简体   繁体   中英

Cant trigger a jquery drag event properly

I'm trying to trigger the drag event of a div named ts1 when user drags the mouse anywhere in the body.

the div ts1 has a drag function on it (jquery tagsphere). What i'm trying actually to achieve is to trigger $('#ts1').tagsphere() or something

after about 3-4 hours testing and looking for answers, this is my best result:

$('body').bind("drag dragstart dragend",function(event){
            $("#ts1").trigger(event);
            return false;
        });

BUT this still doesn't trigger it....

why? what am i doing wrong? is there a solution out there already that works? cant seem to find 1

EDIT

Sorry guys...seems to be too complicated for me..abandoning post.

It seems the dragging function isn't bound to 'ts1' but rather a different element created by the tagsphere function, thus making my question irrelevent.

use triggerHandler instead of trigger :

$('body').bind("drag dragstart dragend",function(event){
                    $("#ts1").triggerHandler('drag');
                    return false;
                });

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