From Market Ruler Help
Jump to: navigation, search

__CR.ready is a function which takes two parameters:

  1. a function with signature function (context) { ... }
  2. an optional context parameter which is passed as the first parameter

Example usage:

__CR.ready(function (cr) {
  if (document.getElementById('message-sent')) {
    cr.track("newsletter", null,"email"));
}, __CR);

The function passed in may be executed after the DOMContentLoaded event in a browser, often called the DOM Ready event. If the DOM Ready has already occurred in the current browser window, the passed in function is called immediately (but asynchronously).

The value for this in the passed-in function is typically set to the browser global object window.

This function should be used when you wish to access aspects of the Document Object Model in the browser, but are not certain when your code is running and you wish to ensure it runs after the DOM is loaded. It is equivalent to the jQuery Ready function, but does not require jQuery.

Any function passed into __CR.ready is guaranteed to be executed once and only once.

This function is only available as of September 12, 2018.

See also