JQuery + Flowplayer: flowplayer cannot access element
I want to insert a Flowplay开发者_JS百科er into a div created entirely with JQuery (using .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:
flowplayer($div.get(0), 'flowplayer/flowplayer-3.2.7.swf');
There is a method which take a DOM element in the documentation Flowplayer documentation
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".
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.
Enjoy..
I think you should use .live():
.live() - Attach an event handler for all elements which match the current selector, now and in the future. http://api.jquery.com/live/
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. Simply adding the div worked for us.
精彩评论