From 71732dceb6613dab28d6eef96fa155acc91af7ce Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 17 Jul 2015 15:34:31 +0200 Subject: [IMP] web: module can be asynchronous loaded if it return a deferred Each module can return a deferred. In that case, the module is marked as loaded only when the deferred is resolved, and its value is equal to the resolved value. The module can be rejected (unloaded). This will be logged in the console as info. Remove if_dom_contains from the website, the modules return a rejected deferred if the DOM doesn't contains the seleted values. --- .../static/src/js/website_mass_mailing.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'addons/website_mass_mailing/static/src') diff --git a/addons/website_mass_mailing/static/src/js/website_mass_mailing.js b/addons/website_mass_mailing/static/src/js/website_mass_mailing.js index 2d0760a202a..330528c04de 100644 --- a/addons/website_mass_mailing/static/src/js/website_mass_mailing.js +++ b/addons/website_mass_mailing/static/src/js/website_mass_mailing.js @@ -119,7 +119,15 @@ animation.registry.newsletter_popup = animation.Class.extend({ } }); -website.if_dom_contains('div.o_unsubscribe_form', function() { +}); + + +odoo.define('mass_mailing.unsubscribe', function (require) { + +if(!$('.o_unsubscribe_form').length) { + return $.Deferred().reject("DOM doesn't contain '.o_unsubscribe_form'"); +} + $('#unsubscribe_form').on('submit', function(e) { e.preventDefault(); @@ -144,6 +152,5 @@ website.if_dom_contains('div.o_unsubscribe_form', function() { $('.alert-info').html('You changes has not been saved, try again later.').removeClass('alert-info').addClass('alert-warning'); }); }); -}); }); -- cgit v1.2.3