Index | OAT homepage | OpenLink Software

# OATDOCghostdrag

- OATDOCghostdrag
- _ _ ghostdrag.js
- _ _ _ _ Objects
- _ _ _ _ _ _ OAT.GhostDrag()
- _ _ _ _ Methods
- _ _ _ _ _ _ OAT.GhostDrag::addSource(element, process, callback)
- _ _ _ _ _ _ OAT.GhostDrag::delSource(element)
- _ _ _ _ _ _ OAT.GhostDrag::clearSources()
- _ _ _ _ _ _ OAT.GhostDrag::addTarget(element)
- _ _ _ _ _ _ OAT.GhostDrag::delTarget(element)
- _ _ _ _ _ _ OAT.GhostDrag::clearTargets()
- _ _ _ _ Example

## ghostdrag.js

Provides drag'n'drop functionality.

### Objects

#### OAT.GhostDrag()

Creates a GhostDrag object.

### Methods

#### OAT.GhostDrag::addSource(element, process, callback)

Marks `element` as draggable. When user drags it, a "ghost" clone is created. Then, the `process` function is called with this clone as argument. If user drags the clone to one of marked target zones, a `callback` is performed with three arguments - `x` , `y` and `target element` .

#### OAT.GhostDrag::delSource(element)

Marks `element` as not draggable.

#### OAT.GhostDrag::clearSources()

Removes all draggable elements from this GhostDrag object.

#### OAT.GhostDrag::addTarget(element)

Marks `element` as a valid ending zone for drag'n'drop.

#### OAT.GhostDrag::delTarget(element)

Marks `element` as not a target zone.

#### OAT.GhostDrag::clearTargets()

Removes all target zones from this GhostDrag object.

### Example

    var product = Dom.create("img");
    var shopping_cart = Dom.create("div");
    var gd = new OAT.GhostDrag();
    var dummyReference = function() {};
    var successReference = function(target, x, y) { alert("Success!"); }
    gd.addTarget(shopping_cart);
    gr.addSource(product, dummyReference, successReference);

Copyright (C) 2005-2008 OpenLink Software