Reputation: 475
In my CRM Dynamics 365 solution I have a form with an embedded webresource A. This webresource A opens another webresource B in a popup-window using window.open
. The opening could of course also be done using Xrm.Utility.openWebResource
.
I would like to utilize jQuery in webresource B. I am aware that CRM itself loads jQuery in some version, which is easy to spot when monitoring network requests and filtering for jquery.
The problem is that the webresource B doesn't have "access" to the jQuery or $-variable. The question is what you would recommend to do in order to use jQuery. I've prioritized a list of some possible solutions:
UPDATE: The main reason for using jQuery was to easily resize an iframe (with random contents) embedded in popup-window which displayed webresource B according to the dimensions of the popup-window.
I decided to lose jQuery altogether and use CSS instead. My solution became this which work nicely in Google Chrome, Windows Edge and Internet Explorer 11:
#externalframe {
width: 100%;
height: 100%;
display: block;
float: left;
}
Upvotes: 1
Views: 1174
Reputation: 27659
If you can access jsquery in webresourceA
then it means that the jquery already exists (as a webresource) in CRM. Find the url(path) of jquery and add it as a reference to the webresourceB
and that's it.
Upvotes: 1
Reputation: 22846
I recommend Encapsulation & Namespacing of jQuery technique.
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!
Upvotes: 1