【发布时间】:2016-07-13 17:53:18
【问题描述】:
基本上,我有以下标记:
<script>
$(function() {
$('.box').on('mousedown', function(e) {
console.log(e);
});
});
</script>
<body ng-controller="MainCtrl">
<ul ui-sortable="sortableOptions" ng-model="list">
<li draggable ng-repeat="item in list">Item: {{item}}</li>
</ul>
<div class="boxes">
Drop to external area: <br/><br/>
<div class="box" style="background: red;"></div>
<div class="box" style="background: yellow;"></div>
<div class="box" style="background: orange;"></div>
</div>
</body>
小提琴:http://plnkr.co/edit/xKw6sSbymA5M8R2v4OGF?p=preview
现在,我希望能够将项目从列表拖放到“外部”容器中。
当用户将项目“放置”到任何彩色区域时,我想知道该事件刚刚发生以及哪个元素受到影响
已尝试在每个 .box 元素上侦听 mousedown/mouseup 事件,但未按预期工作。
【问题讨论】:
-
您需要在目标“外部”容器上捕获 drop 事件。
-
两年前我提出了feature request,但没有运气......
标签: javascript jquery angularjs jquery-ui-sortable