Difference between revisions of "Loading jQuery for instrumenting pages"

From Market Ruler Help
Jump to: navigation, search
Line 1: Line 1:
The <span class="code">__CR.jquery</span> function takes a single parameter which is a callback which has the first parameter the [[jQuery]] global (typically '''window.jQuery''' or '''window.$''').
+
The <span class="code">__CR.jquery</span> function takes two parameters; the first of which is a callback which has the first parameter the [[jQuery]] global (typically '''window.jQuery''' or '''window.$''').
  
The current version of jQuery which is loaded is '''1.11.3'''. It is only loaded if jQuery is '''not''' detected on the page. Detection checks for the existence of the window.jQuery variable being defined.
+
<nowiki>cr.jquery(loaded, force)</nowiki>
 +
 
 +
The second parameter is a boolean value which should be <code>true</code> to force the script to load a '''new version of jQuery''' from the [[ConversionRuler]] servers. You should '''only do this if an incompatible version of jQuery exists on the page.'''
 +
 
 +
Otherwise, the current version of jQuery which is loaded is '''1.11.3'''. It is only loaded if jQuery is '''not''' detected on the page '''and''' the 2nd parameter is '''not''' <code>true</code>. Detection checks for the existence of the window.jQuery variable being defined.
  
 
An example of its usage is:
 
An example of its usage is:
Line 15: Line 19:
  
 
For more information, read the [http://api.jquery.com/ jQuery documentation].
 
For more information, read the [http://api.jquery.com/ jQuery documentation].
 +
 +
== Revisions ==
 +
 +
* '''May 17, 2018''' - Added the <code>force</code> parameter to <code>__CR.jquery</code>
  
 
== See also ==
 
== See also ==

Revision as of 18:34, 17 May 2018

The __CR.jquery function takes two parameters; the first of which is a callback which has the first parameter the jQuery global (typically window.jQuery or window.$).

cr.jquery(loaded, force)

The second parameter is a boolean value which should be true to force the script to load a new version of jQuery from the ConversionRuler servers. You should only do this if an incompatible version of jQuery exists on the page.

Otherwise, the current version of jQuery which is loaded is 1.11.3. It is only loaded if jQuery is not detected on the page and the 2nd parameter is not true. Detection checks for the existence of the window.jQuery variable being defined.

An example of its usage is:

<script>
window._crq = window._crq || [];
window._crq.push(function (cr) {
    cr.jquery(function ($) {
        // Do jQuery stuff here using $ as the loaded version of jQuery
    });
});
</script>

For more information, read the jQuery documentation.

Revisions

  • May 17, 2018 - Added the force parameter to __CR.jquery

See also