web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to use JQuery capabilities in a Web Resource?

(0) ShareShare
ReportReport
Posted on by

Hi,

I have created an HTML page as a web resource where I want to display some data.

The HTML page contains a lot many controls, and I am easily able to achieve changing a few attributes of the HTML controls using "document.getElementById". But there is an issue when I want to do the same thing using JQuery functions. For example, $('#...') something says, "$" is undefined.

However, in my HTML page, I am loading JQuery library that gets loaded by default with the CRM. That means, the web resource has following tag to make sure that the JQuery library gets loaded to be used in the web resource.

<script src="../sln_jquery" type="text/javascript"></script>

Here, "sln" is the prefix of publisher of my custom solution. I can also see the JQuery file getting loaded when I try to check using the Developer Tools in IE.

Any idea on why this would be happening? I know, this is possible, just need to find a way!

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Jason M. Cosman Profile Picture
    5,234 Moderator on at

    Hello Nirman;

    Would you be able to post a picture of your uploaded jquery file? Just to ensure that it isn't in a folder.

    Also it should be with a .js in your file name like:

    <script src="../Jquery.js" type="text/javascript"></script>

    I hope this helps Nirman!

  • Suggested answer
    nghieppham Profile Picture
    4,755 on at

    Hi Nirman,

    Please add GlobalContext to your HTML webresourc, it will fix your bug.

    msdn.microsoft.com/.../gg328541.aspx

    or you can follow this link to add JQuery to your Html page.

    arunpotti.wordpress.com/.../html-webresource-example-in-crm

    Regards,

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    2,667 on at

    Hi Nirman,

    You should have to pass ClientGlobalContext Web Reference in to your Html Page.

    Check this: stackoverflow.com/.../how-do-you-add-jquery-in-a-html-page-as-a-web-resource-in-dynamics-crm-2011

    And <script src="../sln_jquery" type="text/javascript"></script> this script's src file should be with .js file & folder name should mention.

    Hope it helps you !!

    Thanks,

  • Nirman Profile Picture
    on at

    Hi Pham,

    Thanks for the links.

    I have already added GlobalContext to the HTML web resource.

    I referred to the other blog, but it suggests to add reference of the JQuery library which is provided in the SDK. Can we not use the one which CRM loads by default?

    By using following, I am trying to use the same library which CRM loads for us, thus to avoid additional resource.

    <script src="../sln_jquery" type="text/javascript"></script>


  • Nirman Profile Picture
    on at

    Hi Jason,

    Thanks for your reply.

    I have not added JQuery file as a web resource, instead, I am trying to use the same JQuery file provided by default by CRM.

    I believe, we should be able to use to same JQuery file provided by CRM instead of adding another JQuery as a web resource. Am I correct in this?

    Also, a strange thing is that when I click on "sln_jquery" in the developer tools (in IE), it opens the scripts file, but the script file suggests the JQuery version 1.7.1, whereas the one which comes Dynamics CRM online at the moment is 2.1+.

    Thanks

  • Nirman Profile Picture
    on at

    any help on this please?

  • Suggested answer
    necsa Profile Picture
    3,455 on at
  • Suggested answer
    ChrisC Profile Picture
    630 on at

    In my experience the safe and supported way is to load a private namespaced instance of jquery as Scott has suggested in his SparkleXrm blog. This keeps your code isolated and ensures future-proofing and it's easy to add your own webresource in HTML page.

    However if you need very generic jQuery functions in js webresources I have had success re-using the CRM instance and I would be very surprised if they gave up on jQuery.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans