I am using the latest version of Telerik MVC extensions with my ASP.NET MVC 3 razor application. I have also downloaded the latest version of jQuery.
I have my jQuery file in a different directory as to what comes default with Visual Studio. The reason for this is because I have downloaded the latest version of jQuery jquery-1.6.2.min.js. I have my Telerik MVC content and scripts directories in a different directory. As to what I have seen the Telerik scripts needs the jQuery file to be loaded first. I have deleted the content and scripts directories that come by default with an ASP.NET MVC application.
Telerik scripts directory:
~/Assets/telerikaspnetmvc/2011.2.712/Scripts/
My jQuery directory:
~/Assets/JavaScripts/jQuery/
I changed the ScriptRegistrar to that of below:
@(Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.DefaultPath("~/Assets/telerikaspnetmvc/2011.2.712/Scripts/")
.Compress(true)
)
.Scripts(scripts => scripts
.AddGroup("JavaScriptAssetLocation", group => group
.DefaultPath("~/Assets/JavaScripts/jQuery/")
.Add("jquery-1.6.2.min.js")
.Compress(true)
)
)
.jQuery(false)
)
This gave me an error. I swapped the 2 around so that it can read jQuery first as below but it still seems to load the default Telerik JavaScript files first and results in errors. This is the changed code:
@(Html.Telerik().ScriptRegistrar()
.Scripts(scripts => scripts
.AddGroup("JavaScriptAssetLocation", group => group
.DefaultPath("~/Assets/JavaScripts/jQuery/")
.Add("jquery-1.6.2.min.js")
.Compress(true)
)
)
.DefaultGroup(group => group
.DefaultPath("~/Assets/telerikaspnetmvc/2011.2.712/Scripts/")
.Compress(true)
)
.jQuery(false)
)
What am I doing wrong here? Please provide code samples as to how it must be done.
Just another question. Do I need to specify Compress(true) per group or is once enough? And jQuery(false) needs to be specified where? Only after DefaultGroup? Or anywhere?