angular-dragdrop icon indicating copy to clipboard operation
angular-dragdrop copied to clipboard

access the actual data-object that is being dragged

Open ashishtilara opened this issue 8 years ago • 3 comments

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.

ashishtilara avatar Apr 28 '16 04:04 ashishtilara

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 avatar May 04 '16 13:05 elarion

@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.

ashishtilara avatar May 04 '16 23:05 ashishtilara

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)'}"

ashishtilara avatar May 04 '16 23:05 ashishtilara