I want to insert a Flowplayer 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)
I want to insert a Flowplayer 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)
Share Improve this question edited May 17, 2011 at 16:07 salezica asked May 17, 2011 at 15:51 salezicasalezica 77.2k27 gold badges112 silver badges168 bronze badges 5- $(div) instead of $div ? – Satish Commented May 17, 2011 at 15:54
-
@Satish Nope,
$div = $('bla');
, I use the$
to mark JQuery objects among my variables. – salezica Commented May 17, 2011 at 15:57 - @has the div definitely been added to the DOM yet before calling the reference to the id? – Brian Scott Commented May 17, 2011 at 15:57
- try doing a console.log to print out and check if the "id"exists – Satish Commented May 17, 2011 at 15:58
- @Brian duh, I was about to answer 'yes' and decided to recheck my code. I had confused a variable name, and for some reason fate decided that the script could run without errors using the other name. HOWEVER: now, without plaining, nothing happens – salezica Commented May 17, 2011 at 16:07
4 Answers
Reset to default 2If "$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./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.