Drag object into sortable list - AngularJS

后端 未结 2 453
轮回少年
轮回少年 2021-02-01 08:08

Problem:

I\'m trying to recreate the Draggable + Sortable functionality from jQuery and can\'t get the dropped element to go into my array of objects.

I want t

2条回答
  •  醉梦人生
    2021-02-01 08:50

    You should be able to do every thing you need in your link function.

    myapp.directive("menuDrag", function () {
    
        return{
            restrict: "A",
            link:     function (scope, element, attrs) {
                var item = $(".draggable").draggable(
                    {
                        snap:   true,
                        revert: false,
                        // scope:".dropable"
                        //scope: "tasks"
                    }
                )
                var target = $(".dropable").droppable({
    
                    greedy:     true,
                    hoverClass: "warning",
                    accept:     ".draggable"
                })
    
    
                item.on("drag", function (evt) {
                    item.css = ('background-color', 'red');
                    //evt.stopPropagation();
                    //evt.preventDefault();
                })
    
    
                target.on("over", function (evt) {
    
                    target.css('background-color', 'blue')
    
                    return false;
                });
                target.on("out", function (evt) {
                    dropBox.css('background_color', 'red');
    
    
                    return false;
                });
                target.on("drop", function (evt) {
                    alert("Droped");
                    return false;
                });
                //dragEnterLeave(evt);
            }
        }
    })
    

提交回复
热议问题