How to drag&drop elements onto a calendar with angular directives only

前端 未结 2 1338
清歌不尽
清歌不尽 2021-01-03 07:56

I am trying to implement a drag&drop calendar with angular directives. The calendar uses the ui-calendar (https://github.com/angular-ui/ui-calendar), a complete AngularJ

相关标签:
2条回答
  • 2021-01-03 08:56

    Haven't used angular-dragdrop, but the documentation says that the config object should contain a onDrop property. Try replacing jqyoui-droppable="{multiple:true}" with jqyoui-droppable="{multiple:true, onDrop: 'drop'}". angular-dragdrop seem to expect onDrop to be a string with the name of a function on the scope.

    0 讨论(0)
  • 2021-01-03 08:59

    Another way to accomplish this is use JqueryUI draggable. Create directive and pass the attributes via "elem". You can include title as an attribute as well.

    .directive('dragMe', function() {
      return {
        restrict: 'A',
        link: function(scope, elem, attr, ctrl) {
          elem.data('event', {
              title: $.trim($(elem).text()), // use the element's text as the event title
              stick: true // maintain when user navigates (see docs on the renderEvent method)
            });
          elem.draggable({
              zIndex: 999,
              revert: true,      // will cause the event to go back to its
              revertDuration: 0  //  original position after the drag
            });
        }
      };
    })

    0 讨论(0)
提交回复
热议问题