Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    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.

  • Users who have thanked ohgod for this post:

    RadGH (10-15-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •