How to use jQuery
When using jQuery in your templates (productlist, moreinfo or skins), we need to make sure only one instance of jQuery is loaded.
If jQuery gets loaded multiple times (for instance from different urls, or different versions), the second instance will overwrite the first, including any triggers or extensions which may have been loaded.
To prevent this from happening we have put two functions in place:
- When multiple lines including a script from the same url exist (for instance one from the skin and one from the productlist) then only one is rendered in the resulting html page
- To make sure jQuery is loaded persistent from the same url and version, there is a alias which can be used which automatically fills in the src attribute with the needed url
The extension which can be used for this is myshop-resource-alias:jquery
:
<script type="text/javascript" src="myshop-resource-alias:jquery"> </script>
This extension is used in our standard templates, so if you use it in any custom templates, it will ensure that jQuery works the way you expect it to.
Currently we use the 1.4.2 version of jQuery.
Post your comment on this topic.