angular-dragdrop
angular-dragdrop copied to clipboard
access the actual data-object that is being dragged
Hi
I am trying to make confirmation dialog have some values from the object that is being dragged and using onDrop
and beforeDrop
, but they seem to not have the information about the object.
Is it possible to get an example?
Thank you.
Hey, may be you can try something with onStart like storing your dragged obj in your scope then reused this on onDrop event. If you find any native way to do this tell me !
@elarion, what I did was added a beforeDrop
on draggable element, passing index, then cloning the object before showing the model, user then changes some attributes of the object from fields in model and when they hit submit, I reject the promise, but add the new object into array manually. so it looks like object was dropped and not cancelled.
here is my beforedrop
handler
beforePersonDrop = function (event, ui, id) {
var _this = this,
person = _.cloneDeep(_this.people[id]),
modalInstance,
defer = prvt.$q.defer();
modalInstance = $uibModal.open({
templateUrl: "partials/model.html",
backdrop: "static",
controller: "controllers.ModelCtrl",
controllerAs: "ctrl",
resolve: {
person: function () {
return person;
}
}
});
modalInstance.result.then(function (person) {
_this.list4.push(person);
defer.reject();
}, function () {
defer.reject();
});
return defer.promise;
}
and draggable property:
jqyoui-draggable="{index: {{$index}}, animate: true, placeholder: 'keep', beforeDrop: 'ctrl.beforePersonDrop($index)'}"