diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-07-17 15:34:31 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-07-22 12:15:24 +0200 |
| commit | 71732dceb6613dab28d6eef96fa155acc91af7ce (patch) | |
| tree | 1f33280ca569fd23912a640a79ec8d878d934bfc /addons/website_mass_mailing/static/src/js | |
| parent | dfad968515b523ebc900a0ba0fa1b111626f6149 (diff) | |
[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.
Diffstat (limited to 'addons/website_mass_mailing/static/src/js')
| -rw-r--r-- | addons/website_mass_mailing/static/src/js/website_mass_mailing.js | 11 |
1 files changed, 9 insertions, 2 deletions
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'); }); }); -}); }); |
