From ec6083c0c3b0de2aa9f794ff0a3602df2ce5f1c8 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 20 Jun 2016 12:18:02 +0200 Subject: [PATCH] [FIX] web_tour: observe when dom is ready Start observing the DOM (MutationObserver) only when it's ready. --- addons/web_tour/static/src/js/tour_service.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/web_tour/static/src/js/tour_service.js b/addons/web_tour/static/src/js/tour_service.js index 4856e920076..608e63527fe 100644 --- a/addons/web_tour/static/src/js/tour_service.js +++ b/addons/web_tour/static/src/js/tour_service.js @@ -33,15 +33,19 @@ return session.is_bound.then(function () { } }, 500, {leading: false}); var observer = new MutationObserver(check_tooltip); - var observe = observer.observe.bind(observer, document.body, { - attributes: true, - childList: true, - subtree: true, - }); + var observe = function () { + $(function () { + observer.observe(document.body, { + attributes: true, + childList: true, + subtree: true, + }); + }); + }; // Enable the MutationObserver for the admin or if a tour is running, when the DOM is ready if (session.is_admin || tour.running_tour) { - $(observe); + observe(); } // Override the TourManager so that it enables/disables the observer when necessary if (!session.is_admin) {