Difficulty implementing video player when using template

3 posts, 3 answers
  1. Answer
    Ray avatar
    8 posts
    Member since:
    Jan 2013

    Posted 06 May 2013 Link to this post

    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.

    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()
    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>
                            <dt>Some Info: </dt>
                            <dt>Some More Info:</dt>
    # window.onload = playVideoNow() #
    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.

    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.



  2. Answer
    Petyo avatar
    2444 posts

    Posted 08 May 2013 Link to this post

    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.

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Answer
    Ray avatar
    8 posts
    Member since:
    Jan 2013

    Posted 08 May 2013 Link to this post

    Hi Peyto,

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


Back to Top