HTML5拖放移动版(HTML5 Drag & Drop for Mobile)
这是我对WHATWG HTML5 拖放的实现:
function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); } function drop(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("Text"); ev.target.innerHTML+=" <p>"+document.getElementById(data).innerHTML+"</p>"; }
.div { width:350px;height:70px;padding:10px;border:1px solid #aaaaaa; }
<div class="div" ondrop="drop(event)" ondragover="allowDrop(event)"></div> <div class="div" ondrop="drop(event)" ondragover="allowDrop(event)"> <button id="drag1" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button> <button id="drag2" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button> </div>
它适用于谷歌浏览器,但不适用于iOS或Android。 我已经阅读了有关此内容的其他主题,但大多数建议使用jQuery或JavaScript插件。
是否有可能使HTML拖放实现在iOS和Android(移动设备)上运行?
This is my implementation of WHATWG HTML5 Drag and Drop:
function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); } function drop(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("Text"); ev.target.innerHTML+=" <p>"+document.getElementById(data).innerHTML+"</p>"; }
.div { width:350px;height:70px;padding:10px;border:1px solid #aaaaaa; }
<div class="div" ondrop="drop(event)" ondragover="allowDrop(event)"></div> <div class="div" ondrop="drop(event)" ondragover="allowDrop(event)"> <button id="drag1" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button> <button id="drag2" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button> </div>
It works fine in Google Chrome, but not in iOS or Android. I have read other topics about this but most of them suggest using jQuery or a JavaScript plugin.
Is it possible to make the HTML drag and drop implementation work on iOS and Android (mobile devices)?
原文:https://stackoverflow.com/questions/21350874
更新时间:2024-01-08 09:01
最满意答案
从您的控制器对
login.html
的定义中删除[]
。angular.module("scrumboard.demo") .controller("LoginController", ["$scope", "$http", "$location", LoginController]);
remove
[]
from your controller's defination forlogin.html
.angular.module("scrumboard.demo") .controller("LoginController", ["$scope", "$http", "$location", LoginController]);
相关问答
更多-
我认为问题是道路。 无论如何,你应该考虑不使用Process调用Symfony命令。 控制台组件允许调用命令,例如在控制器中。 文档示例: // src/Controller/SpoolController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sym ...
-
如果您的控制器与Main类位于一个单独的包中,您可以尝试将组件扫描添加到主类,指向您拥有控制器的包。示例: @ComponentScan({ "x.y.z.myPackage1", "x.y.z.myPackage2" }) If your controller is in a separate package from your Main class you can try adding a component scan to your main class pointing to the packag ...
-
您使用了错误的Application 。 您应该替换use Symfony\Component\Console\Application; 通过use Symfony\Bundle\FrameworkBundle\Console\Application; You used the wrong Application. You should replace use Symfony\Component\Console\Application; by use Symfony\Bundle\FrameworkBund ...
-
您正在宣布该模块两次, //在controller.js文件中删除此行 var app = angular.module("myApp", []); /// app.controller("homingController", function($scope) { $scope.firstName = "John"; $scope.lastName = "Doe"; }); DEMO You are declaring the module twice, //Remove this line in yo ...
-
从您的控制器对login.html的定义中删除[] 。 angular.module("scrumboard.demo") .controller("LoginController", ["$scope", "$http", "$location", LoginController]); remove [] from your controller's defination for login.html. angular.module("scrumboard.dem ...
-
迁移到Angular 1.6.1组件后未注册控制器(Controller not registered after migrating to Angular 1.6.1 Component)[2022-02-10]
我发现我的问题类似于我之后发布的问题。 我已经添加了该帖子的答案,并会引用其他有同样问题的人来参考帖子的答案5,Angular.js UI-Router模板没有加载, Angular.js UI-Router模板没有加载 。 作为迁移到Angular 1.5.x或更高版本的人的注释,请确保至少升级到ui-router的版本1,因为我不相信早期版本的ui支持组件语法。 我已经添加了对plunk的视图,可以在以下网址找到增强版本: https ://plnkr.co/edit/IfqtANj1ocGsZcLIj ... -
你可以这样做: controller = ActionController::Base::ApplicationController.new controller.extend(MyConcern) controller.concern_method "hello world" You can do this: controller = ActionController::Base::ApplicationController.new controller.extend(MyConcern) cont ...
-
控制器上的方法是实例方法,而不是类方法。 类方法用self.定义self. 。 很难从控制台触发控制器操作,因为您错过了整个上下文。 您没有会话,没有请求,没有响应。 所有这些都使得在控制器操作中使用代码变得困难。 如果您需要从外部触发代码(控制台,机架任务,其他代码)。 您应该将代码提取到它自己的类中。 The methods on your controller are instance methods, not class methods. Class methods are defined with ...
-
使用angular.module API意外重新定义模块也可能导致未知的控制器错误,如以下示例所示。 angular.module("app", ["ngAnimate"]).controller("agencies_Ctrl", fn1); angular.module("app", ["ngAnimate"]).controller("focus_groups_Ctrl", fn2); 要解决此问题,请确保仅在整个项目中使用angular.module(name, [requires])语法定义每 ...
-
设置您的控制器路径; Set your controller path like ;