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

Load jquery from cdn

3 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Giovanni De Lazzari
Top achievements
Rank 1
Giovanni De Lazzari asked on 10 May 2012, 08:24 AM
Sorry but I don't understand the documentation about radscriptmanager
My question is
I have a page that usually load jquery.js from my site
now I would like to use radScriptmanager with the code below  :
 and all is ok 
but why I have to inlcude the link to jquery.js  in the head section of the page ?
( some like <script src="/js/jquery-1.6.2.min.js" type="text/javascript"></script> ) 
if telerik use jquery - why this is not usable from all the code in the page? 
I test it with this simple script 
 if (jQuery) {
            alert('jQuery is loaded!');
        }
If I don't inlcude jquery in the head section the alert don't fire
thanks in advance
ciao



<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableCdn="true">
        <Groups>
       <telerik:ScriptReferenceGroup>
           <Scripts>
               <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js"   />
               <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
               <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryPlugins.js" />
           </Scripts>
       </telerik:ScriptReferenceGroup>
   </Groups>
   </telerik:RadScriptManager>

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 15 May 2012, 08:36 AM
Hi Giovani,

You don't have to manually include jQuery on the page. We include jQuery on all pages that contain telerik controls or if it is manually declared in the script manager as it is in your case. The reference, however, resides in $telerik.$ instead of jQuery.

This is how you can access the instance:

var $ = null;
 
Sys.Application.add_load(function() { $ = $telerik.$; });

Or you can simply use $telerik.$ whenever you need jQuery.

All the best,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Giovanni De Lazzari
Top achievements
Rank 1
answered on 03 Jun 2012, 07:44 PM
thanks , I did what yoy suggest but doesn't work
maybe I write something wrong
here is my code
<form id="form1" runat="server">
   <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
       <CdnSettings TelerikCdn="Enabled" />
       <StyleSheets>
           <telerik:StyleSheetReference Path="/css/Stile.css" />
         
       </StyleSheets>
   </telerik:RadStyleSheetManager>
   <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableCdn="true">
        <Groups>
       <telerik:ScriptReferenceGroup>
           <Scripts>
               <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js"   />
               <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
               <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryPlugins.js" />
           </Scripts>
       </telerik:ScriptReferenceGroup>
   </Groups>
   </telerik:RadScriptManager>
        <script language="javascript" type="text/javascript">
            var $ = null;
            Sys.Application.add_load(function () { $ = $telerik.$; });
       </script>
   <div id="wrapper">....
 after that 
I write the test code in the page ( the code above is on master page)
that doesn't work

<script type="text/javascript">
    $(document).ready(function () {
           alert('hi');
       });
   </script>


but if I write  this code , it work
<script type="text/javascript">
       $telerik.$(document).ready(function () {
           alert('hi');
       });
   </script>

What I need is to use the jquery reference $ everywhere 
I can't change my tons of code from $ to $telerik.$  please advice me
thanks
0
Genady Sergeev
Telerik team
answered on 06 Jun 2012, 12:11 PM
Hi Giovanni,

Actually there is no  need to use Sys.Application.add_load. You can simply attach $ to $telerik.$. For reference, I am attaching sample project that demonstrates the approach.

Greetings,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Giovanni De Lazzari
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Giovanni De Lazzari
Top achievements
Rank 1
Share this question
or