#foreach($product in $products)
<a class="nosto-product-image" href="$!product.url">
<img src="$product.thumb(2)" alt="">
<a class="nosto-product-name" href="$!product.url">$!product.name</a>
Targeting the right window object
Since the Nosto JS is loaded in an iframe, the scripts are executed in another window context. This is useful since it prevents the script from clashing with other scripts on the site. The downside is that manipulating the DOM and initializing scripts from the template gets a little trickier, since the scripts are not loaded in the same window as the site. To use the scripts you are loading on the site, you need to choose the right window object: _targetWindow. For example if you are loading jQuery on your site, instead of calling $ or jQuery you would use it by calling _targetWindow.$ or _targetWindow.jQuery.
// will not work
// will work
Selecting elements with jQuery
However if the same template is included on the page more than once, the selector would match multiple elements and it would be likely to cause problems. As when enclosing CSS styles in the template, you can use the $divId variable to create a selector that only matches elements inside the current recommendation slot:
// outputs the current slot ID into the selector
This way the selector will be unique each time the template is included into the page and there won’t be any issues with the selector matching more than the intended elements.