This question is locked. New answers and comments are not allowed.
Rommel Manalo
Top achievements
Rank 1
Rommel Manalo
asked on 19 Sep 2009, 06:04 PM
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")
)
6 Answers, 1 is accepted
0
Accepted
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.
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.
0
Rommel Manalo
Top achievements
Rank 1
answered on 23 Sep 2009, 01:40 AM
Ok, thanks for the great help. I think it may work also
0
Rommel Manalo
Top achievements
Rank 1
answered on 23 Sep 2009, 10:39 AM
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.
0
Accepted
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.
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.
0
Rommel Manalo
Top achievements
Rank 1
answered on 24 Sep 2009, 02:18 AM
Thanks for the info.
0
Brian Mains
Top achievements
Rank 1
answered on 11 Nov 2009, 02:56 AM
Hello,
I think this would be a great feature... please add me as a requestor too.
Brian
I think this would be a great feature... please add me as a requestor too.
Brian