2016-07-14 8 views
0

Ich benutze Dragula JavaScript, um die Container-Elemente dynamisch anhängen. Wenn ich drag and drop trage, möchte ich die Ziel-Eltern-ID und die Element-ID erhalten. Ich habe das Bild mit dem gleichen verbunden. Sobald ich diese IDs bekomme, möchte ich sie in der Datenbank speichern. Ich benutze PHP und AJAX.So erhalten Sie Artikel-ID und Ziel-ID (Container-ID) beim Drag & Drop-Artikel mit Dragula Js

function drop(item, target) { 
    var parent = getParent(item); 
    if (_copy && o.copySortSource && target === _source) { 
    parent.removeChild(_item); 
    } 
    if (isInitialPlacement(target)) { 
    drake.emit('cancel', item, _source, _source); 
    } else { 
    drake.emit('drop', item, target, _source, _currentSibling); 

    } 
    cleanup(); 
} 

drag and drop image

Antwort

0

Ich habe meine solution..tried als below..its wie ein Zauber arbeiten ..

function drop(item, target) { 
var parent = getParent(item); 
if (_copy && o.copySortSource && target === _source) { 
parent.removeChild(_item); 
} 
if (isInitialPlacement(target)) { 
drake.emit('cancel', item, _source, _source); 
var itemid=item.id; 
var targetid = target.id; 

//initialize function to update status 
update_function(itemid, targeid); //this function called in main page 
} else { 
drake.emit('drop', item, target, _source, _currentSibling); 
var itemid=item.id; 
var targetid = target.id; 

//initialize function to update status 
update_function(itemid, targeid); //this function called in main page 
} 
cleanup(); 
}