JQuery in ISML Templates

jQuery is frequently used in ISML templates. B2C Commerce supports versions up to and including jQuery 1.3.2.

Avoid using the # character in jQuery or JavaScript because it's reserved in ISML templates and can cause problems.

Note: Generally, if you follow the best practices of unobtrusive JavaScript and progressive enhancement, you will not mix HTML and JavaScript behavior, so this is unnecessary.

However, there might be cases where you need to use the # character. In these cases, instead of the following code:

<a id="id-to-select" href="...">...</a>

<script type="text/javascript">
jQuery("#id-to-select").click(function() {
    // Code here
});
</script>

Use the following code:

<script type="text/javascript">
jQuery("a[id='id-to-select']").click(function() {
    // Code here
});
</script>

Alternatively, the following notation:

<a href="#">Link</a>
is correctly written in ISML as
<a href="${'#'}">Link</a>
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.