You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/08/26 18:24:11 UTC
[2/7] fauxton commit: updated refs/heads/master to 6c9a5a6
Fix double render when a new template is rendered
This fixes the double render issue we are getting. This is very
noticeable on a first render. The fix is to wait for the layout to
rendered and then only render the views.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/6f145e8f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/6f145e8f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/6f145e8f
Branch: refs/heads/master
Commit: 6f145e8f7dd386216ff921687628f4c921685fe9
Parents: 895d13c
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Aug 25 11:45:06 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Aug 26 18:22:41 2014 +0200
----------------------------------------------------------------------
app/core/base.js | 2 +-
app/core/layout.js | 2 +-
app/core/routeObject.js | 20 +++++++++++++++-----
3 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/6f145e8f/app/core/base.js
----------------------------------------------------------------------
diff --git a/app/core/base.js b/app/core/base.js
index 61da5e4..3d51e06 100644
--- a/app/core/base.js
+++ b/app/core/base.js
@@ -62,7 +62,7 @@ function(Backbone, LayoutManager) {
manage: true,
disableLoader: false,
- useRAF: false,
+ useRAF: true,
forceRender: function () {
this.hasRendered = false;
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/6f145e8f/app/core/layout.js
----------------------------------------------------------------------
diff --git a/app/core/layout.js b/app/core/layout.js
index 8d589e7..2faa230 100644
--- a/app/core/layout.js
+++ b/app/core/layout.js
@@ -48,7 +48,7 @@ define([
// existing views in the layout.
_.each(this.layoutViews, function(view){view.removeView();});
this.layoutViews = {};
- this.render();
+ return this.render().promise();
},
setView: function(selector, view, keep) {
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/6f145e8f/app/core/routeObject.js
----------------------------------------------------------------------
diff --git a/app/core/routeObject.js b/app/core/routeObject.js
index 898afcb..c3b998c 100644
--- a/app/core/routeObject.js
+++ b/app/core/routeObject.js
@@ -92,26 +92,36 @@ function(FauxtonAPI, Backbone) {
args: args
};
- this.setTemplateOnFullRender(masterLayout);
+ var promiseLayout = this.setTemplateOnFullRender(masterLayout);
this.triggerBroadcast('beforeEstablish');
var renderAllViews = _.bind(this.renderAllViews, this, options),
establishError = _.bind(this.establishError, this),
renderComplete = _.bind(this.renderComplete, this),
+ callEstablish = _.bind(this.callEstablish, this),
promise = this.establish();
- this.callEstablish(promise)
- .then(renderAllViews, establishError)
- .then(renderComplete);
+ // Only start the view rendering process once the template has been rendered
+ // otherwise we get double renders
+ promiseLayout.then(function () {
+ callEstablish(promise)
+ .then(renderAllViews, establishError)
+ .then(renderComplete);
+ });
},
setTemplateOnFullRender: function(masterLayout){
+ var promise = $.Deferred();
// Only want to redo the template if its a full render
if (!this.renderedState) {
- masterLayout.setTemplate(this.layout);
this.triggerBroadcast('beforeFullRender');
+ masterLayout.setTemplate(this.layout).then(promise.resolve, promise.reject);
+ } else {
+ promise.resolve();
}
+
+ return promise;
},
callEstablish: function(establishPromise) {