Error: Unable to create directory /var/www/vhosts/justswell.org/subdomains/blog/httpdocs/wp-content/uploads/2013/06. Is its parent directory writable by the server?
by admin

Even more Drag&Drop coolness between your desktop and your browser!

Posted in DD, Javascript, Swell

We are making more & more progress with the native DnD API, and being native means fully taking advantage of Event Bubbling.

In essence this means that if you want to make for example a datatable with a lot of rows without attaching events to them (remember the flyweight pattern?) you’ll only need to set your draggable element at a higher level in the hierarchy to get the DnD behavior applied on all children nodes (marked with the draggable attribute), that’s powerful and of course, reduces a lot the memory footprint of your web application.

A lot of components could benefit of this approach, Treeview, Datatable, Listview and so on.

Another part of the example shows another level of interaction between the browser and desktop, and we are sure this one will get a lot of attention and excitement!

Swell drag&drop in actionAnd the code :)

var proxyElement = html.div(null, html.span({
    'cls' : 'dd-proxy-icon'
}), html.span('Moo'));
 
 
var draggableRows = new Swell.Lib.DD.Draggable('bleh', {
    'delegate' : true,
    'proxy'  : true,
    'proxyOverride'    : proxyElement,  
    'dataCallback' : function(dt) {
        var _currentEl = this.getDragEl().current(), _stdOut = [];
 
        for(var _n = 0, _l = _currentEl.childNodes.length; _n < _l; _n++) {
            if(_currentEl.childNodes[_n].nodeType === 1) {
                var _text = $(_currentEl.childNodes[_n]).text();
                _stdOut.push(Swell.Core.trim(_text));
            }
        }
        this.setData(dt, 'text/plain', _stdOut.join("\t"));
    }
});
 
var dropTarget = new Swell.Lib.DD.Droppable('moo');
 
dropTarget.ondrop = function(e, draggable) {
    if(!!draggable) {
        draggable.getDragEl().appendTo($('moo').current().tBodies[0]);
    }
}

Tags: , , , ,

3 Responses to “Even more Drag&Drop coolness between your desktop and your browser!”

  1. 1
    Tweets that mention Even more Drag&Drop coolness between your desktop and your browser! « SwellJS – another big fish in the sea -- Topsy.com Says:

    [...] This post was mentioned on Twitter by runixo and Jon Clark. runixo said: genial ♻ @dalmaer: [...] Native drag and drop demos. This time; seamless D&D between browser and desktop spreadsheet http://bit.ly/4a5qp5 [...]

  2. 2
    Swell js Part4, more native drag and drop! « Position Absolute Says:

    [...] More information here! [...]

  3. 3
    Eternity Says:

    No more s***. All posts of this qultiay from now on

Leave a Reply