We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

How to solve issues with custom script not running in Templates?

We do not support custom Angular directives in the Piano templates. Only the directives listed here.

The <custom-script> will run standard JavaScript.

The custom script is running first and sometimes not all elements of the website are loaded yet at this time. Typically the workaround, in this case, would be to check whether any known element is populated before you allow the custom script to run with the user of a time-out function.

You can use two options for embedding custom scripts:

  • the script tag (<script></script>)

  • the custom-script directive (<custom-script> or <div custom-script></div>).

The second option is preferable (as it prevents unexpected breakdowns associated with errors that you may have made in the code) but has a number of limitations:

1. You CANNOT use and include external scripts files
2. You DO NOT have access to Angular: you CANNOT change, add directives, components, you cannot use functions as controllers
3. You CAN use the reference to the DOM elements
4. You CAN use JQuery library
5. You CAN write a simple custom script without using Angular

When using the tag script(<script>), you have no restrictions, but you yourself are responsible for the occurrence of breakdowns in the application. Our recommendation is to adjust your functionality for using with the tag custom-script.

Last updated: