CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   script.aculo.us Draggables question (http://www.codingforums.com/showthread.php?t=150165)

RadGH 10-14-2008 05:36 PM

script.aculo.us Draggables question
 
Scriptaculous Draggables website

I'm trying to create my own object class "tile", which essentially is like an icon on your desktop with functions like... tile.recycle (delete via effect.poof), tile.icon (icon element id) and more.

However, I don't fully understand the object scope of their classes. For example, this small bit of code allows me to drop my div on a 'recycler div' and it "poofs" (well, puffs) away with an animation.

Code:

Droppables.add('recycler',
{
        accept:'tile',
        onDrop:function(){
                Effect.Puff('tile_01');
        }
});

This does work for all the divs with class "tile", however, I need to take the dropped element's ID instead of using the static 'tile_01'. With the code above, dropping any tile will poof tile_01 (first div).

I tried using this, but I need more of a that. The "triggering div" you might call it. I've looked through the documentation, but it wasn't very helpful.

ohgod 10-14-2008 06:40 PM

so you're trying to figure out which draggable hit your droppable, right?

onDrop will automatically get the element that was dropped on it... then it's just a matter of getting the id. see below. identify() is part of prototype.


Code:

onDrop:function(element){
                Effect.Puff($(element).identify());
        }

that is untested, but based off my own working code. if it doesn't get you closer try dropping an alert in there to see what is being passed.


All times are GMT +1. The time now is 06:33 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.