addDrag

registers drag area

void addDrag(id|HTMLElement node,object ctrl);
nodeid|HTMLElementhtml node or ID
ctrlobjectobject code of the drag control methods

Example

<div id="myDrag"><div>
 
webix.DragControl.addDrag("myDrag",{
    move:function(source, target, obj){
        var index = -1;
        if (target) 
            //defining position of the target item
            index = obj.getIndexById(target); 
            obj.add({
                title:"new item",
                rank: "0"
            }, index);
    }
});

Related samples

Details

When a draggable div with myDrag ID is dropped over the datatable item, it takes its place (defined by index). If index cannot be retrieved, the item takes the last position and is added to the end of the datatable.

See also
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support, connect with other developers, and share your feedback there.