This is a migrated thread and some comments may be shown as answers.

Difficulty implementing video player when using template

2 Answers 98 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Ray
Top achievements
Rank 1
Ray asked on 06 May 2013, 05:44 PM
I am trying to get an instance of a video player (JWPlayer) to cooperate with a template I am using. I am very new to this so please forgive me if this solution is obvious to some.

Objective:
When a user clicks a kendo button on the default.aspx page, a kendo window pops up and is formatted based on a template I pass in. I'd like to display the video inside that kendoWindow inside of a div.


This javascript method is located inside my default.aspx:
                  function playVideoNow()
                  {
                   jwplayer("details-container").setup({
});
This is the template that I have sitting inside of default.aspx:
    <script type="text/x-kendo-template" id="template">
                    <div id="details-container">
                    <h2>Video Name</h2>
                    <em>Video Date</em>
                    <dl>
                        <dt>Some Info: </dt>
                        <dt>Some More Info:</dt>
                    </dl>
                </div>
# window.onload = playVideoNow() #
  
    </script>
Problem:
When I open the kendoWindow, it complains that it cannot locate "details-container". I assume this is because it is out of scope for the window, since the javascript method is executing from default.aspx, it doesn't know that "details-container" exists.

Question:
So what is the proper way to implement this? Should I run jwplayer.setup() in the template? What would this look like? Some example code would really help to get me started.


Thanks,

Ray


2 Answers, 1 is accepted

Sort by
0
Accepted
Petyo
Telerik team
answered on 08 May 2013, 03:23 PM
Hi Ray,

The # window.onload = playVideoNow() # code executes the playVideoNow method immediately when the template is executed (and before its contents are inserted into the DOM). You should call the playVideoNow function after the template is rendered. 

I would also like to clarify that the window widget does not build a separate iframe - its contents reside in the same document. Opening a kendo window will not cause a window.onload event.

Regards,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Ray
Top achievements
Rank 1
answered on 08 May 2013, 03:37 PM
Hi Peyto,

thank you this clears up my lack of understanding. I have it cooperating as expected now. Thanks for you help on this.

Cheers,

Ray
Tags
Templates
Asked by
Ray
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Ray
Top achievements
Rank 1
Share this question
or