- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试对我的应用程序实现拖放操作,但发现了一个问题。我正在使用 https://github.com/fatlinesofcode/ngDraggable 中的 ngDraggable 模块。我可以拖动 div 并将其移动到屏幕上,但无法放下它。如果我把它扔掉,它会飞回原来的地方,继续在原来的地方移动。我正在尝试做与重新排序示例中相同的事情。
这是我的代码:
JS:
$scope.draggableObjects = [
{name: 'one'},
{name: 'two'},
{name: 'three'},
{name: 'four'},
{name: 'five'},
{name: 'six'}
];
$scope.onDragComplete=function(data,evt){
console.log("drag success, data:", data);
};
$scope.onDropComplete = function (index, obj, evt) {
var otherObj = $scope.grids[index];
var otherIndex = $scope.grids.indexOf(obj);
$scope.grids[index] = obj;
$scope.grids[otherIndex] = otherObj;
}
HTML:
<div ng-repeat="grid in draggableObjects" ng-drop="true" ng-drop-success="onDropComplete($index, $data,$event)" class="grids ng-scope">
<div class="grid grid-normal ng-scope" ng-drag="true" ng-drag-data="grid" ng-class="grid.name" class="ng-binding one">Add a new chart</div>
</div>
所以我有对象列表和回调函数,但它不起作用。另外,我注意到我的代码与示例没有添加拖动和拖过类,不知道为什么,也许这会导致问题。
最佳答案
您需要提供 2 个 div
: 1. 拖自 2. 拖至
拖动到div
时使ng-drag="true"
您还可以使用其中提供的功能。
对于第一个 div
,您需要在此处给出 ng-drag="true"ng-drag-data="e"
"e"
> 是来自某个数据源的元素。
关于javascript - ngDraggable 无法将网格放置到其位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32433953/
我正在尝试对我的应用程序实现拖放操作,但发现了一个问题。我正在使用 https://github.com/fatlinesofcode/ngDraggable 中的 ngDraggable 模块。我可
我在一个用户案例中使用 ngDraggable,该用户案例由一个 div 内的一个 div 组成,并且它们都是可拖动的。 我也想重新排序子元素和父元素。 但是,当我尝试移动 child 时, pare
我正在为我支持的元素制作一个可拖动的 div 元素。我找到了这个 AngularJS directive允许元素可拖动。 我修改了指令以更改起始位置,但是当我进行更改时鼠标方向没有反转(即向右移动鼠标
我在 ng-drag 元素上有 ng-click,当我开始移动元素时一切正常,但是当我停止它时,那个元素激活了我的 ng-click,我怎样才能避免 ng-click? 我正在使用 ngDragga
我正在使用 AngularJS 和一个名为 ngDraggable 的组件开发一个应用程序,但我在处理触摸事件时遇到了一些问题。当执行拖动的触摸事件时,控制台上会显示错误: Uncaught Type
我是一名优秀的程序员,十分优秀!