[FIX] website_blog: change_background doesn't work occasionally

Some time new background image, which I set via "Change cover" button don't saved. Because super is called before the jsonRpc and don't wait that the background is saved.
This commit is contained in:
Christophe Matthieu 2015-12-01 17:38:33 +01:00
parent fc61bfe993
commit ae175d1574
1 changed files with 7 additions and 3 deletions

View File

@ -30,14 +30,18 @@ $(document).ready(function() {
$('body').on('click', '#clear_cover',_.bind(this.clean_bg, self.rte.editor, vHeight)); $('body').on('click', '#clear_cover',_.bind(this.clean_bg, self.rte.editor, vHeight));
}, },
save : function() { save : function() {
var res = this._super(); var self = this;
var _super = this._super;
if ($('.cover').length) { if ($('.cover').length) {
openerp.jsonRpc("/blogpost/change_background", 'call', { return openerp.jsonRpc("/blogpost/change_background", 'call', {
'post_id' : $('#blog_post_name').attr('data-oe-id'), 'post_id' : $('#blog_post_name').attr('data-oe-id'),
'image' : $('.cover').css('background-image').replace(/url\(|\)|"|'/g,''), 'image' : $('.cover').css('background-image').replace(/url\(|\)|"|'/g,''),
}).then(function () {
return _super.call(self);
}); });
} else {
return this._super();
} }
return res;
}, },
clean_bg : function(vHeight) { clean_bg : function(vHeight) {
$('.js_fullheight').css({"background-image":'none', 'min-height': vHeight}); $('.js_fullheight').css({"background-image":'none', 'min-height': vHeight});