Advanced Settings

Running Scripts Before and After Renders

Check how to run your custom scripts at a specific time

Sometimes, you might need to run a script in DanDomain either before or after has rendered products. 

The most common use-case, is if you want to add's live-search to a Search-Field that is inserted after the initial page-load, or manually add recommendations to an Ajax popup.

For this, you can use the function  clerkBeforeRenderVariables() run your script before renders and clerkAfterRenderVariables() to run it after it loads.

For example:

<script type="text/javascript">
function clerkBeforeRenderVariables() {
      '<span class="clerk" data-template="@live-search" data-live-search-categories="true" data-live-search-categories-title="Kategorier" data-live-search-products-title="Produkter" data-bind-live-search=".SearchField_SearchPage:eq(1)"></span>');