× Ask and contribute to general questions and how-to for DecoNetwork products.

Deco 8 - jQuery load

2 months 1 week ago #21061 by Ellis
Deco 8 - jQuery load was created by Ellis
Is jQuery automatically loaded for DN8?

We use to load jQ in DN7.5 to auto set the currency and use other jQ features. We have temporarily done the same but if it is already loaded we are now wasting load time.

If it is loaded is there a special syntax to get to it? Normally we use explicit jQuery(..) not $(...) syntax?

Thanks,
John

Please Log in or Create an account to join the conversation.

2 months 1 week ago #21063 by gregp
Replied by gregp on topic Deco 8 - jQuery load
Hi,

In DN8 we are now using jQuery.
The tricky part is that sometimes we include it in the head tag (on more complex pages that depend on javascript to render), and sometimes it is included asynchronously (using defer) at the bottom of the page (to make the page load/render very fast).
If you need to rely on jQuery, you need to register your function/callback with a dnOnLoad() call.
You can use the "JQuery" variable to reference JQuery, or use our variable/shortcut "$dnj" (which we use in case JQuery has been included multiple times). You should not use "$" as this conflicts with prototype.

dnOnLoad(function() {
var phNumEl = $dnj(".dn-phone-number"); //or JQuery(".dn-phone-number");
phNumEl.html("555-5555-555");
});

Any callbacks registered with dnOnLoad() will get called once all DN javascripts on the page have been loaded.

Note , response from one of our devs :)

Cheers,
Greg

Please Log in or Create an account to join the conversation.

2 months 1 week ago #21077 by Ellis
Replied by Ellis on topic Deco 8 - jQuery load
Thank you Deco team. :-)

For all who want to force the currency on your page load, Deco now makes it very simple. Here is an example of a force to US dollars (currency array element 1).

<script type="text/javascript">
dnOnLoad(function() { dnSelectCurrency('1'); });
</script>
</body>
</html>
The following user(s) said Thank You: gregp

Please Log in or Create an account to join the conversation.

Time to create page: 0.107 seconds
Powered by Kunena Forum