Giter VIP home page Giter VIP logo

Comments (5)

DanielSchuech avatar DanielSchuech commented on September 27, 2024 3

You will not get the source.model directly but you can detect it by yourself.

We will get the DOM Element of the dragged element. Through this we could determine the model:

$scope.$on('another-bag.drop-model', function (el, target, source) {debugger
    var movedContent = target.contents()[0].data;
    var index = $scope.many2.indexOf(movedContent);

    //dropped item $scope.many2[index]
    //you can modify it here
    console.log('dragged ' + $scope.many2[index]);
  });

You can find it also in the following Plunkr: click

I know thats this exemple is really simple and it isn´t mostly the case that the model will be displayed directly. But you could gain other opportunities like setting id`s, classes or other attributes with a title of the model to determine the dropped model. I don´t know another solution yet.

from angularjs-dragula.

soniram avatar soniram commented on September 27, 2024 1

I am using a list of objects as my model, which I set in the div using ng-repeat. When I drag an item from this list to another div, I would like to change/modify some property of the object that I dragged depending on the object that I dropped it ?

I inspected the model-drop event callback parameters (el, source, target) but I cannot find anything like "source.model" (containing the object that I dragged) and "target.model" (containing the object that I dropped the source).

Does such a feature exist or I'm missing something ?

from angularjs-dragula.

soniram avatar soniram commented on September 27, 2024

Sorry.. this is the second container

                <div class="car-orders" dragula="'bag-a'" dragula-model="car.orders" layout="column">
                    <div ng-repeat="order in car.orders">

from angularjs-dragula.

DanielSchuech avatar DanielSchuech commented on September 27, 2024

I am not sure if i ve understood your problem. Maybe provide a plunkr. It would be easier to have a look into it. Or maybe give some more info what you want to do.

The drop-moel event will be fired when the changes are finished in the given dragula model. You can then use your model to task you want to do.

Edit:
So in the written event you can use your vm.orders and car.orders model. Both are modified through the drag&drop. The parameters of the function will not return the models itself. So you need to implement this event in the specific controller where you have access to your model(s).

from angularjs-dragula.

bevacqua avatar bevacqua commented on September 27, 2024

Please ask on Slack. https://dragula-slackin.herokuapp.com/

from angularjs-dragula.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.