Component Loading

Performing actions when a TryNow component is completely loaded

Background: Component Loading

Sometimes it may be necessary to perform an action immediately after a TryNow component such as the button has fully loaded.

To facilitate this a method onLoad is available and can be accessed via window.trynow.components.

How the onLoad method works

The method should be used as follows:

window.trynow.components.onLoad('[COMPONENT_NAME], CALLBACK_FUNCTION')

As you can see, only two attributes are required: the component name and the function to be executed once the component has loaded.

The component name must be valid. Below is a list of the available options that can be used.

  • ctaButton
  • toggle
  • hiwModal
  • faq
  • howItWorks
  • pdpEntryPoint
  • pdpEntryPointOneLine

Example

The following example executes a simple console log when the component is loaded:

window.trynow.components.onLoad('ctaButton', () => {
	console.log('CTA Button has been loaded')
})