简体   繁体   English

jQuery + Flowplayer:flowplayer无法访问元素

[英]JQuery + Flowplayer: flowplayer cannot access element

I want to insert a Flowplayer into a div created entirely with JQuery (using .append() ). 我想将Flowplayer插入完全使用JQuery创建的div中(使用.append() )。

When execution gets to this point: 执行到这一点时:

$div.attr('id', 'flowplayer');
flowplayer('flowplayer', 'flowplayer/flowplayer-3.2.7.swf');

UPDATE: No more exception , the player just doesn't appear. 更新: 没有更多的例外 ,播放器不会出现。 No errors appear on my console. 我的控制台上没有出现错误。

What am I missing? 我想念什么?

(What's posted above is not my actual code, and I may have the wrong idea of what's relevant and what's not, so if you need to see more code, please ask) (上面发布的不是我的实际代码,对于相关的内容和不相关的内容我可能有误解,因此,如果需要查看更多代码,请询问)

If "$div" is your jQuery object have you tried: 如果“ $ div”是您的jQuery对象,您是否尝试过:

flowplayer($div.get(0), 'flowplayer/flowplayer-3.2.7.swf');

There is a method which take a DOM element in the documentation Flowplayer documentation Flowplayer文档中有一个采用DOM元素的方法

I think you should use .live() : 我认为您应该使用.live()

.live() - Attach an event handler for all elements which match the current selector, now and in the future. .live() -为当前和将来与当前选择器匹配的所有元素附加事件处理程序。 http://api.jquery.com/live/ http://api.jquery.com/live/

Same problem I faced today..found solution for this. 我今天遇到的同样问题..为此找到了解决方案。

The reason was that the script was loaded in the header apparently. 原因是该脚本显然已加载到头文件中。 By default the Javascript placement in SWF Tools' Embedding settings (admin/settings/swftools/embed) is set to "Body". 默认情况下,SWF工具的“嵌入”设置(admin / settings / swftools / embed)中的Javascript位置设置为“正文”。

I switched this to "Header" - something I shouldn't have done. 我将其切换为“页眉”,这是我不应该做的。 After searching all the way around I eventually find out that this was the culprit for the behaviour described above. 经过一路搜索,我最终发现这是上述行为的罪魁祸首。 I switched it back to "Body", which solved the problem. 我将其切换回“ Body”,从而解决了该问题。

Enjoy.. 请享用..

Not sure whether the API has changed or something like that but, we used to just have the elements as elements, without the use of a div. 不确定API是否已更改或类似的更改,但是,我们过去只是将元素作为元素,而未使用div。 Simply adding the div worked for us. 只需添加div就可以为我们工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM