From f7e83b69c6850f731834f636e3dbb404eca45b8d Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 9 Aug 2019 11:34:19 +0000 Subject: [FIX] website_event: clean local events snippet before save The local events snippets is an empty HTMLElement which is filled by JavaScript on page loading. Before this commit, the filled content was saved in database. This does not create a real problem as the content is reloaded as soon as the page loads but you can see old events flickering before the new events are actually loaded. Now the snippet is cleaned before saving. This also allows to add default content with a custo so that it is shown during the events loading (as we are currently doing on odoo.com...). closes odoo/odoo#35597 Signed-off-by: Quentin Smetz (qsm) --- addons/website_event/static/src/js/website_geolocation.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'addons/website_event/static/src/js/website_geolocation.js') diff --git a/addons/website_event/static/src/js/website_geolocation.js b/addons/website_event/static/src/js/website_geolocation.js index 5d1f3d26775..2315213ca05 100644 --- a/addons/website_event/static/src/js/website_geolocation.js +++ b/addons/website_event/static/src/js/website_geolocation.js @@ -12,12 +12,22 @@ sAnimation.registry.visitor = sAnimation.Class.extend({ start: function () { var defs = [this._super.apply(this, arguments)]; var self = this; + var $eventList = this.$('.country_events_list'); + this._originalContent = $eventList[0].outerHTML; defs.push(this._rpc({route: '/event/get_country_event_list'}).then(function (data) { if (data) { - self.$('.country_events_list').replaceWith(data); + self._$loadedContent = $(data); + $eventList.replaceWith(self._$loadedContent); } })); return $.when.apply($, defs); }, + /** + * @override + */ + destroy: function () { + this._super.apply(this, arguments); + this._$loadedContent.replaceWith(this._originalContent); + }, }); }); -- cgit v1.2.3