From c258439fa43f7a2982d1a0bab0e868153ba2ba06 Mon Sep 17 00:00:00 2001 From: Yann Gouffon Date: Fri, 9 Mar 2018 10:13:38 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20better=20script=20initialization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generators/app/templates/assets/base.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/generators/app/templates/assets/base.js b/generators/app/templates/assets/base.js index 17e785f..f661f06 100644 --- a/generators/app/templates/assets/base.js +++ b/generators/app/templates/assets/base.js @@ -1,12 +1,17 @@ +/* globals jQuery, document */ + // You will use that file to import all your scripts // Ex: import gallery from './gallery'<% if (svgIcons) { %> import svgIcons from '../icons/svg-icons'; svgIcons(); // Must run as soon as possible<% } %> +const init = () => { + // Run your imported scripts + // Ex: gallery(); +}; + (function ($) { - $(document).ready(function () { - // Run your imported scripts - // Ex: gallery(); - }); + $(document).ready(() => init()); })(jQuery); +document.addEventListener('ToolboxReady', () => init());