Microsoft Edge Try Microsoft Edge A fast and secure browser that's designed for Windows 10 Get started

This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use. Learn more
Microsoft Microsoft
Dynamics Community
    • Platform
    • Stories
    • Datacenters
    • Microsoft Azure
    • Find a solution provider
    • Enterprise mobility
    • Office mobility
    • Windows mobility
    • Microsoft Surface
    • Microsoft Lumia
      • Office 365 for business
      • Plans and pricing
      • Office 365 for SMB
      • Office 365 for Enterprise
      • Skype for business
      • Overview
      • Pricing and licensing
      • Microsoft Dynamics AX
      • Microsoft Dynamics GP
      • Microsoft Dynamics NAV
      • Microsoft Dynamics SL
      • Windows 10 for business
      • Windows 10 for Internet of Things
      • Windows devices
      • Microsoft SQL Server
      • Microsoft Power BI
      • Microsoft Cortana Intelligence
      • Operations Management Suite
      • System Center
    • No results
    Sign in
      • Ask a Question
      • Get Started
        • Earn Badges
        • View Badges
        • Compete on Leaderboards
        • View Leaderboards
      • Become an Expert
      • Recommend a Blog
      • Introduce Yourself
      • Provide Feedback
      • Microsoft Dynamics AX
      • Microsoft Dynamics CRM
      • Dynamics 365, Business Edition
      • Dynamics 365, Enterprise Edition
      • Microsoft Dynamics GP
      • Microsoft Dynamics NAV
      • Partner Community
      • Other Products
    Microsoft Dynamics CRM
    • Microsoft Dynamics CRM
    • Microsoft Dynamics Marketing
    • Microsoft Social Engagement
    • Parature, from Microsoft
    BlogsVideosExpertsCustomerSource

    • Sign In/Sign Up
    • Home
    • Forums
    • Blogs
    • Videos
    • Experts
    • Support
    • Communities
      • Microsoft Dynamics AX
      • Microsoft Dynamics CRM
      • Microsoft Dynamics GP
      • Microsoft Dynamics NAV
      • Microsoft Dynamics SL
      • Other Products
      • Partner Community
      • Envision

    jQuery and jQuery UI with Dynamics CRM 2011 & 2013

    • Sign In
    • Home
    • Share
      • Twitter
      • LinkedIn
      • Facebook
      • Email
      • Print
    • RSS
    8 Aug 2013 5:51 AM

    Since I’ve been converting Silverlight web resources over to Html & JavaScript and working on www.SparkleXrm.com , I’ve worked extensively with jQuery and jQuery-UI.

    In the early days of Dynamics CRM 2011, you could use both these libraries without a problem, but with the Activity Feeds solution an instance of jQuery appeared that interfered with your custom scripts.
    This is still the case in Dynamics CRM 2013 and so here are some simple steps to ensure your libraries are safe and will co-exist with other instances from other solutions.

    1. Decide on a custom ‘namespace’ for your jQuery library. I am using ‘xrmjQuery’


    2. On the end of your jquery.js script add the following line:

    /* jQuery script goes here */
    window.xrmjQuery = jQuery.noConflict(true);
    
    
    


    3. Inside your jquery_ui.js script (notice the ‘-‘ has been changed to an underscore since CRM doesn’t allow them in web resource names), wrap the whole file in the following lines:

    (function ($,jQuery) {
    	/*! jQuery UI Goes here */
    })(window.xrmjQuery,window.xrmjQuery);
    
    
    


    4. Inside your JavaScript web resource that use jQuery and jQuery-UI, wrap your code in the following:

    (function($){
    // Your Javascript goes here and can reference $ as usual
    // e.g. var someField = $('#fieldName');
    })(window.xrmjQuery);
    
    
    


    This technique is called encapsulation and namespacing of jQuery.

    My friend Carsten also has a blog post on a similar theme.

    www.SparkleXrm.com uses the same technique and namespace is also ‘xrmjQuery’, so if you would like to quickly get access to the jQuery libraries in Dynamics CRM, you can install the SparkelXrm managed solution and include the web resource named ‘sparkle_/js/SparkleXrmUI_Dependancies.js’ – this is a single library that has both jQuery, jQueryUI as well as a few other goodies such as Knockout JS!

     

    @ScottDurow

    Read Complete Post and Comments
    Tags: Dynamics CRM 2011 Dynamics CRM 2013 Sparkle XRM

    Meet the Author

    Scott Durow picture
    Scott Durow (MVP)
    Works for Develop1 Ltd in United Kingdom
    @scottdurow
    LinkedIn
    YouTube
    Blog
    Website

    About Develop 1

    Scott is a passionate Dynamics CRM solution specialist and the author of the Ribbon Workbench for Dynamics CRM. His blog brings you technical insight into all things Dynamics CRM.

    Microsoft Dynamics CRM

    Get help on your Microsoft Dynamics CRM solution from qualified experts in the forums, read blogs and how-to articles, and watch videos.
    Join group
    RSS

    Recommended Content

    Asynchronous loading of JavaScript in CRM 2013
    by Scott Durow on 24 Sep 2013
    • 0 comments
    Spell check add-on for Dynamics CRM 2011/2013
    by Deepesh161 on 18 Nov 2014
    • Verified Answer
    Chrome Dynamics CRM Developer Tools
    by Scott Durow on 27 Jan 2014
    • 0 comments
    jQuery error in Dynamics CRM 2011.
    by Mohsin Ali on 28 May 2014
    • Suggested Answer
    There is something rather different about Dynamics 365 Business Process Flows!
    by Scott Durow on 13 Mar 2017
    • 0 comments
    View More

    Top Tags

    Dynamics CRM 2011 Dynamics CRM 2013 dynamics crm 2015 Dynamics CRM 2016 Dynamics365 Ribbon Workbench Sparkle XRM Version 9.0
    What's new
    • New Surface Pro
    • Xbox One X
    • Xbox One S
    • Surface Laptop
    • Windows 10 apps
    • Office apps
    • Mixer
    Store & Support
    • Account profile
    • Download Center
    • Sales & support
    • Returns
    • Order tracking
    • Store locations
    • Support
    Education
    • Microsoft in education
    • Office for students
    • Office 365 for schools
    • Deals for students & educators
    • Microsoft Azure in education
    Enterprise
    • Microsoft Azure
    • Enterprise
    • Data platform
    • Find a solutions provider
    • Microsoft partner resources
    • Microsoft AppSource
    • Manufacturing & resources
    • Financial services
    Developer
    • Microsoft Visual Studio
    • Windows Dev Center
    • Microsoft Developer Network
    • TechNet
    • Microsoft Virtual Academy
    • Microsoft developer program
    • Channel 9
    • Office Dev Center
    Company
    • Careers
    • About Microsoft
    • Company news
    • Privacy at Microsoft
    • Investors
    • Diversity and inclusion
    • Accessibility
    • Security
    English (United States)
    • Contact Us
    • Privacy & Cookies
    • Terms of Use
    • Trademarks
    • © Microsoft 2017