From 23b6b96fbc4dccf5d6bba6eda2e04ddf8a9d3224 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 13 Dec 2012 15:57:14 +0100 Subject: [PATCH] [IMP] pad: add abord for $.get request bzr revid: chm@openerp.com-20121213145714-b9d4f2u8iqdg8r1m --- addons/pad/static/src/js/pad.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index 5b33fd3eaa1..5cd2ac622cb 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -7,9 +7,6 @@ openerp.pad = function(instance) { start: function() { this._super.apply(this, arguments); var self = this; - this.on('click', '.oe_pad_switch', function(){ - self.$el.toggleClass('oe_pad_fullscreen'); - }); this.on('change:effective_readonly',this,function(){ self.renderElement(); }); @@ -37,6 +34,9 @@ openerp.pad = function(instance) { renderElement: function(){ var self = this; var value = this.get('value'); + if (this.pad_loading_request) { + this.pad_loading_request.abort(); + } if(!_.str.startsWith(value,'http')){ this.configured = false; this.content = ""; @@ -46,24 +46,22 @@ openerp.pad = function(instance) { this.content = ''; }else{ this.content = '
... Loading pad ...
'; - $.get(value+'/export/html').success(function(data){ - if(!self.get('effective_readonly')){ - return false; - } + this.pad_loading_request = $.get(value+'/export/html') + .done(function(data){ groups = /\<\s*body\s*\>(.*?)\<\s*\/body\s*\>/.exec(data); data = (groups || []).length >= 2 ? groups[1] : ''; self.$('.oe_pad_content').html('
'); self.$('.oe_pad_readonly').html(data); }).error(function(){ - if(!self.get('effective_readonly')){ - return false; - } self.$('.oe_pad_content').text('Unable to load pad'); }); } } this._super(); this.$('.oe_pad_content').html(this.content); + this.$('.oe_pad_switch').click(function(){ + self.$el.toggleClass('oe_pad_fullscreen'); + }); }, });