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

Deco 8 - jQuery load

2 weeks 1 day ago #21061 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?


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

2 weeks 21 hours ago #21063 by gregp

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");

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 :)


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

1 week 4 days ago #21077 by Ellis
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'); });
The following user(s) said Thank You: gregp

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

Time to create page: 0.090 seconds
Powered by Kunena Forum