简体   繁体   中英

interact.js drag/drop referencing div

So, this is maybe just a question for interact.js users or I am missing something completely..

I was looking for a javascript library that provides me with drag/drop/scale/rotate and touch functionality for all those given functionalities. So, I stumbled upon interact.js, yet I seem to have a problem referencing elements while using the onDrop method:

I'll just take the code of the interact.js page, which I'm providing you here: http://jsfiddle.net/Zyy2N/2/

The part that is making problems is:

$(event.relatedTarget.id).hide();

which doesn't do anything, yet also doesn't throw any errors. More so:

$('#yes-drop').hide();

works, so does:

console.log(event.relatedTarget.id);

which returns the id as expected. Is this an error?

Solution: One should actually use the correct syntax if one wants code to run correctly...

$('#'+event.relatedTarget.id).hide();

This would actually be a correct and working solution :

http://jsfiddle.net/Zyy2N/3/

Sligthly better:

    $(event.relatedTarget).hide();

http://jsfiddle.net/Zyy2N/8/

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