首页 \ 问答 \ HTML5拖放,还是JqueryUI拖放?(HTML5 Drag and Drop, Or JqueryUI Drag and Drop?)

HTML5拖放,还是JqueryUI拖放?(HTML5 Drag and Drop, Or JqueryUI Drag and Drop?)

我正在开发一个客户端应用程序。 它不需要跨浏览器。 而且我想使用拖放功能。

我熟悉JqueryUI拖放,但我想知道哪一个在性能和编程方面更好,Html5或JqueryUI?

谢谢


I'm developing a client-side application. It doesn't need to be cross-browser. And also I wanna use drag and drop feature.

I'm familiar with JqueryUI Drag and drop, But I wanna know which one is better in performance and easy programming, Html5, or JqueryUI?

thx


原文:https://stackoverflow.com/questions/10378721
更新时间:2022-05-30 22:05

最满意答案

正如您已经想到的那样,看起来代码执行时无法识别播放器元素。 当模块第一次加载时,DOM肯定没有准备好。 在activate()回调函数期间甚至可能没有准备好。 设置jwplayer的正确时间可能在viewAttached()回调中。

您可以在Composition Callbacks部分中阅读有关viewAttached回调的更多信息: http ://durandaljs.com/documentation/Hooking-Lifecycle-Callbacks/

像这样的东西:

define(['jwplayer/jwplayer','durandal/plugins/router','durandal/app'], function (jwplayer,router,app) {

  return {
    router: router,
    activate: function () {
        ...
    },
    viewAttached: function(){
      jwplayer.api('player').setup({
        width: '320',
        height: '40',
        sources: [{
            file: "rtmp://127.0.0.1:1935/vod/mp3:sample_1.mp3"
        },{
            file: "http://127.0.0.1:1935/vod/sample_1.mp3/playlist.m3u8"
        }]
      });
    }
  }; 
});

As you already figured out, it looks like the player element isn't recognized when the code is executing. When the module is loading for the first time, the DOM definitely isn't ready. It may not even be ready during the activate() callback function. The right time to setup the jwplayer is probably in the viewAttached() callback.

You can read more about the viewAttached callback here in the Composition Callbacks section: http://durandaljs.com/documentation/Hooking-Lifecycle-Callbacks/

Something like this:

define(['jwplayer/jwplayer','durandal/plugins/router','durandal/app'], function (jwplayer,router,app) {

  return {
    router: router,
    activate: function () {
        ...
    },
    viewAttached: function(){
      jwplayer.api('player').setup({
        width: '320',
        height: '40',
        sources: [{
            file: "rtmp://127.0.0.1:1935/vod/mp3:sample_1.mp3"
        },{
            file: "http://127.0.0.1:1935/vod/sample_1.mp3/playlist.m3u8"
        }]
      });
    }
  }; 
});

相关问答

更多
  • 好的答案很简单......我只给了div个人名字: 例如:
    Loading the player ...
    Durandal根据需要加载视图和视图模型(按需)。 因此,在您的示例中,使用100个视图和视图模型,您只能加载您使用的视图。 观看浏览器工具的“网络”标签,您可以根据需要看到它们。 此外,一旦它们是本地的,它们被缓存在浏览器中,这是一件好事。 如果您的viewmodel使数据调用为“activate”,则为yes,每次激活它们时都会调用它们。 有关生命周期事件的更多信息,请参阅Durandal文档。 但是,如果您运行optimizer.exe,它将打包所有这些并将它们预先一次性(缩小)带到客户端。 这不是 ...
  • 这似乎工作正常: $("#result").html("Preview video
    "); 我认为这是一个双/单引号问题。 一切都恢复正常。 This seems to work fine: $("#result").html("
  • 我设法使用Lightbox Plus插件的内联灯箱设置功能,如下所述: http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/27431/running-jw-player-in-a-lightbox I managed to get this working using the inline lightbox settings feature of the Lightbox Plus plugin, ...
  • 看起来JW5不支持捕获YouTube错误。 但是,JW6的以下设置有效: YouTube Test Page
    Multipl ... </div> </div> </li> <li class="tw_li clearfix"> <div class="tw_li_con"> <div class="tw_li_title"> <h2><a href="/wenda/durandalgongneng_549" target="_blank">何时使用Durandal的哪些功能?(When to use what features of Durandal?)</a><i>[2022-03-03] </i></h2> </div> <div class="tw_li_cont"> 欢迎加入,并确保浏览http://durandaljs.com/pages/docs/上的文档,该文档提供了一个很好的概述。 当查看允许DOM片段组合的Durandal特征时,我通常会区分单个视图模型(唯一的,只有一个)或构造函数(可能是一个或多个)。 按照惯例,视图模型与同名的* .html文件配对。 例如,看看Durandal的示例shell.html与JumpStarter的shell.html中的shell.html 在两个示例中, shell.js返回一个单例,因为只有一个shell,但第二个示例 ... </div> </div> </li> <li class="tw_li clearfix"> <div class="tw_li_con"> <div class="tw_li_title"> <h2><a href="/wenda/nrwzdurandalzjdsfjb_579" target="_blank">内容未在Durandal中加载的第三方脚本(3rd Party script in content not loading in Durandal)</a><i>[2022-04-22] </i></h2> </div> <div class="tw_li_cont"> 正如您所指出的,Durandal将忽略视图中的script标记。 它们仅从index.html (或其等价物)加载。 您是否能够提前引用脚本(和noscript),将它们放在index.html文件中? 换句话说,它们是否必须动态加载? 旁注:你在“main.js中引用了我所有的其他脚本”是什么意思? 你的意思是它们是RequireJS的路径配置吗? 或者你的意思是说它们在index.html文件(或其等价物)中被引用? After much research I found my answer final ... </div> </div> </li> </ul> </div> <div class="main_right"> <div class="search-out"> <div class="search"> <form action="/wenda" target="_blank" method="get"> <input type="search" autocorrect="off" autocomplete="off" placeholder="请输入关键词" id="q" name="q" value=""> <button class="btn_s" type="submit">搜索</button> </form> </div> </div> <div class="commonh"> <h2>相关文章</h2> <span class="fr"><a href="/jiaocheng" target="_blank">更多</a></span> </div> <div class="right_list"> <li> <a title="HTML5 Drag and Drop【HTML5教程 - 第六篇】" href="/article/HTML5DragandDropHTML5jcdlp_0" target="_blank">HTML5 Drag and Drop【HTML5教程 - 第六篇】</a> </li> <li> <a title="HTML5 入门文章目录汇总" href="/article/HTML5rumenwenzhangmuluhuizong_0" target="_blank">HTML5 入门文章目录汇总</a> </li> <li> <a title="HTML5+Springmvc实现拖拽文件上传 " href="/article/HTML5Springmvcsxtzwjsc_0" target="_blank">HTML5+Springmvc实现拖拽文件上传 </a> </li> <li> <a title="HTML5 Web SQL Database 数据库" href="/article/HTML5WebSQLDatabaseshujuku_0" target="_blank">HTML5 Web SQL Database 数据库</a> </li> <li> <a title="HTML5项目笔记5:使用HTML5 WebDataBase设计离线数据库" href="/article/HTML5xmbj5syHTML5WebDataBasesjlxsjk_0" target="_blank">HTML5项目笔记5:使用HTML5 WebDataBase设计离线数据库</a> </li> <li> <a title="mysql删除外键(Cannot drop index 'FK7D676EBBD0A6D8FD': needed in a foreign key constraint)" href="/article/mysqlscwjCannotdropindexFK7D676E_3" target="_blank">mysql删除外键(Cannot drop index 'FK7D676EBBD0A6D8FD': needed in a foreign key constraint)</a> </li> <li> <a title="jqueryUI插件视频教程01_简介和样式操作" href="/article/jqueryUIcjspjc01_jjhyscz_0" target="_blank">jqueryUI插件视频教程01_简介和样式操作</a> </li> <li> <a title="孔浩JQuery、jqueryUI、jquery validate、comet视频教程" href="/article/khJQueryjqueryUIjqueryvalidatecometspjc_1" target="_blank">孔浩JQuery、jqueryUI、jquery validate、comet视频教程</a> </li> <li> <a title="HTML5 Video元素【HTML5教程 - 第三篇】" href="/article/HTML5VideoysHTML5jcdsp_0" target="_blank">HTML5 Video元素【HTML5教程 - 第三篇】</a> </li> <li> <a title="HTML5 Geolocation【HTML5教程 - 第十篇】" href="/article/HTML5GeolocationHTML5jcdsp_0" target="_blank">HTML5 Geolocation【HTML5教程 - 第十篇】</a> </li> </div> <div class="commonh"> <h2>最新问答</h2> <span class="fr"><a href="/wenda" target="_blank">更多</a></span> </div> <div class="right_list"> <li> <a title="获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)" href="/wenda/huoqumvcdisplaymodehouzhui_283" target="_blank">获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)</a> </li> <li> <a title="如何通过引用返回对象?(How is returning an object by reference possible?)" href="/wenda/yyfhdx_312" target="_blank">如何通过引用返回对象?(How is returning an object by reference possible?)</a> </li> <li> <a title="矩阵如何存储在内存中?(How are matrices stored in memory?)" href="/wenda/juzhencunchuzaineizhong_536" target="_blank">矩阵如何存储在内存中?(How are matrices stored in memory?)</a> </li> <li> <a title="每个请求的Java新会话?(Java New Session For Each Request?)" href="/wenda/qingqiujavaxinhui_485" target="_blank">每个请求的Java新会话?(Java New Session For Each Request?)</a> </li> <li> <a title="css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)" href="/wenda/cssfddivzzdbth1_439" target="_blank">css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)</a> </li> <li> <a title="无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)" href="/wenda/tuxiangcaffeyuceyilei_557" target="_blank">无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)</a> </li> <li> <a title="xcode语法颜色编码解释?(xcode syntax color coding explained?)" href="/wenda/xcodeyufayansebianmajieshi_364" target="_blank">xcode语法颜色编码解释?(xcode syntax color coding explained?)</a> </li> <li> <a title="在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)" href="/wenda/access2010runtimezsoffice2000xdg_422" target="_blank">在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)</a> </li> <li> <a title="从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)" href="/wenda/ddwebzjtxcsfwq_528" target="_blank">从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)</a> </li> <li> <a title="从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))" href="/wenda/jbbfzwjbljxbb_417" target="_blank">从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))</a> </li> <li> <a title="西安哪有PLC可控制编程的培训" href="/wenda/xanyplckkbcpx_36" target="_blank">西安哪有PLC可控制编程的培训</a> </li> <li> <a title="在Entity Framework中选择基类(Select base class in Entity Framework)" href="/wenda/entityframeworkzhongxuanjilei_415" target="_blank">在Entity Framework中选择基类(Select base class in Entity Framework)</a> </li> <li> <a title="在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)" href="/wenda/androidzccwsjjxrqbwnullslxl_307" target="_blank">在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)</a> </li> <li> <a title="电脑二级VF有什么用" href="/wenda/diannaoerjivfshenmeyong_16" target="_blank">电脑二级VF有什么用</a> </li> <li> <a title="Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)" href="/wenda/datamapperrubytianjiahookfangfa_475" target="_blank">Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)</a> </li> <li> <a title="金华英语角." href="/wenda/jinhuayingyujiao_31" target="_blank">金华英语角.</a> </li> <li> <a title="手机软件如何制作" href="/wenda/sjrjzz_103" target="_blank">手机软件如何制作</a> </li> <li> <a title="用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)" href="/wenda/yyandroidwebviewztxbcsxwcd_150" target="_blank">用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)</a> </li> <li> <a title="注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)" href="/wenda/wdypylphp_555" target="_blank">注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)</a> </li> <li> <a title="如何读R中的大数据集[复制](How to read large dataset in R [duplicate])" href="/wenda/durzhongdashujujifuzhi_350" target="_blank">如何读R中的大数据集[复制](How to read large dataset in R [duplicate])</a> </li> <li> <a title="Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)" href="/wenda/unityheighmapdxkddxzdfblgx_375" target="_blank">Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)</a> </li> <li> <a title="如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)" href="/wenda/tzpipedoutputstreamxcxrygzpipedi_163" target="_blank">如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)</a> </li> <li> <a title="python的访问器方法有哪些" href="/wenda/pythonfangwenqifangfa_93" target="_blank">python的访问器方法有哪些</a> </li> <li> <a title="DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)" href="/wenda/devicenetworkinformation_95" target="_blank">DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)</a> </li> <li> <a title="在Ruby中对组合进行排序(Sorting a combination in Ruby)" href="/wenda/rubyzhongzuhepaixu_148" target="_blank">在Ruby中对组合进行排序(Sorting a combination in Ruby)</a> </li> <li> <a title="网站开发的流程?" href="/wenda/wangzhankaifadeliucheng_75" target="_blank">网站开发的流程?</a> </li> <li> <a title="使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)" href="/wenda/zendframeworkzjoinsqljssj_199" target="_blank">使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)</a> </li> <li> <a title="条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)" href="/wenda/tdgslxgsmsbhgz_207" target="_blank">条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)</a> </li> <li> <a title="透明度错误IE11(Transparency bug IE11)" href="/wenda/toumingducuowuie11_313" target="_blank">透明度错误IE11(Transparency bug IE11)</a> </li> <li> <a title="linux的基本操作命令。。。" href="/wenda/linuxdejibencaozuomingling_66" target="_blank">linux的基本操作命令。。。</a> </li> </div> </div> </div> </div> <div style="clear:both;"></div> <div class="footer"> <div class="mainbox"> <div class="info"> <p>Copyright ©2023 <a href="https://www.peixunduo.com" target="_blank">peixunduo.com</a> All Rights Reserved.<a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备14003112号</a> </p> <p>本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!</p> </div> </div> </div> <script type="text/javascript" src="/resources/js/common.js?v=324"></script> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https'){ bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else{ bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?9eebaceb5e4371a0aad59712a1a1ecff"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>