Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > General Discussions > Load additional javascript after the OnDocumentReady
Telerik MVC Extensions are no longer supported (see this page for reference). In case you have inquiries about Kendo UI Complete for ASP.NET MVC, post them in the pertinent Kendo UI forums.

Answered Load additional javascript after the OnDocumentReady

Feed from this thread
  • Rommel Manalo avatar

    Posted on Sep 19, 2009 (permalink)

    For some odd reason i want to load additional javascripts after the OnDocumentReady(...). As far as I know the UI controls are rendered inside this section. What if I have scenario that I to need to access the variables/objects inside the OnDocumentReady(...). From my observations putting the additional scripts in the Script().Add(...) block will be read first (even there is the document.ready(..) ) than the OnDocumentReady(...).

    I have a proposal for something like this

    <% Html.Telerik().ScriptRegistrar().Scripts(
                s => s.Add("GridPlugIn.js")
               ).OnDocumentReady(%>
               
               var sc = jQuery("#birthdate").value();
               
               <%).AfterOnDocumentReady()..Scripts(
                s => s.Add("file-that-manipulates-the-value-inside-telerik-ondocument-ready.js")
               )

  • Answer Atanas Korchev Atanas Korchev admin's avatar

    Posted on Sep 22, 2009 (permalink)

    Hi Rommel Manalo,

    I think you can use the $.getScript method provided by jQuery to load the JavaScript file

    .OnDocumentReady(() => {%>
          $.getScript("/Scripts/test.js", function () {
                 // code executed when the script is loaded
           });
    <%})

    I hope this helps,
    Atanas Korchev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  • Rommel Manalo avatar

    Posted on Sep 22, 2009 (permalink)

    Ok, thanks for the great help. I think it may work also

  • Rommel Manalo avatar

    Posted on Sep 23, 2009 (permalink)

    If i used the $getscript, i will not benefit from the JavaScript compression that you had, and let say after OnDocumentReady i will still load 4 or more JavaScript files, i think Yslow will complain to me that i should compress/combined those JavaScripts. 

  • Answer Atanas Korchev Atanas Korchev admin's avatar

    Posted on Sep 23, 2009 (permalink)

    Hello Rommel Manalo,

    Indeed with getScript you have to request the files one by one (unless you combine them manually). You can enable gzip compression for static resources such as JavaScript files. Nevertheless using getScript is the only workaround for the time being.

    I have logged your suggestion as a feature request but I cannot promise if it will be implemented for the official release.
    One thing is for sure - if it becomes a popular request we will raise its priority.

    Regards,
    Atanas Korchev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  • Rommel Manalo avatar

    Posted on Sep 23, 2009 (permalink)

    Thanks for the info.

  • Posted on Nov 10, 2009 (permalink)

    Hello,

    I think this would be a great feature...  please add me as a requestor too.

    Brian

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > General Discussions > Load additional javascript after the OnDocumentReady