Load jquery from cdn

4 posts, 0 answers
  1. Giovanni De Lazzari
    Giovanni De Lazzari avatar
    16 posts
    Member since:
    Sep 2006

    Posted 10 May 2012 Link to this post

    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>
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 15 May 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Giovanni De Lazzari
    Giovanni De Lazzari avatar
    16 posts
    Member since:
    Sep 2006

    Posted 03 Jun 2012 Link to this post

    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
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 06 Jun 2012 Link to this post

    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.
Back to Top