JQuery noConflict and JQuery plugins

3 posts, 1 answers
  1. Gene
    Gene avatar
    16 posts
    Member since:
    Jun 2012

    Posted 23 Jun 2010 Link to this post

    I would like to make a suggestion/observation about the use of the JQuery library in the Telerik controls.  First of all, let me say that I am extremely appreciative of your use of it - I love JQuery and think it makes my development life easier.

    That being said, I noticed that, in Telerik's implementation of JQuery, you have the following lines at the end of your jQuery library:

    // Move jQuery to $telerik 
    $telerik.$ = jQuery.noConflict(true); 

    What I wonder is, why are you passing true to noConflict?  In the JQuery docs, it says this:

    If necessary, we can free up the jQuery name as well by passing true as an argument to the method. This is rarely necessary, and if we must do this (for example, if we need to use multiple versions of the jQuery library on the same page), we need to consider that most plug-ins rely on the presence of the jQuery variable and may not operate correctly in this situation.

    This is indeed the problem I am seeing when trying to use jQuery plugins with my installation.  I am having to modify every single plugin, so instead of it passing the jQuery object to the plugin, it passes $telerik.$.  I don't see the need to "hide" the jQuery object in this way.  Why can't we have access to the jQuery object just as it should be, through jQuery and through $?  Currently, to make my coding shorter, I am calling this line after the telerik scripts are loaded:

    window.$ = $telerik.$; 

    This is just so I can use typical jQuery shorthand, like $(document).ready().  What was the need for obscuring the JQuery object in $telerik.$?  Wouldn't it be better to keep it the way it was intended, and allow the developers using your framework to decide whether to call noConflict if they are using other frameworks in addition to yours?


  2. Answer
    T. Tsonev
    T. Tsonev avatar
    2760 posts

    Posted 24 Jun 2010 Link to this post

    Hello Gene,

    Thank you for the excellent question. The reason we use noConflict is exactly the one stated in the documentation - we need to support multiple versions of jQuery on the page.

    We, as component vendor, cannot make assumptions whether the user has jQuery on the page or what version it is. So we do the next best thing and hide the jQuery instance from the global namespace.

    That doesn't mean that we can't undo this. If you want to bring back the jQuery and $ globals use the following script references:

    <telerik:RadScriptManager runat="server" ID="RadScriptManager1"
             <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.jQueryInclude.js" />

    I hope this helps.

    Sincerely yours,
    Tsvetomir Tsonev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. Gene
    Gene avatar
    16 posts
    Member since:
    Jun 2012

    Posted 24 Jun 2010 Link to this post


    Thanks a lot for your quick reply.  That makes perfect sense.  I was not aware of the jQueryInclude, but that's exactly what I needed.  Looking back at the documentation, I see where this is documented now:


    Guess I should have RTFM :-)

Back to Top