FAQ
Repository: couchdb-fauxton
Updated Branches:
   refs/heads/master cfdc7f98f -> 7e99366c4


Fix for lookahead tray redirect problem

This fixes the following problem. To reproduce:
1. On the All Docs page of a database, edit a document.
2. Click Back.
3. Use the lookahead tray to select a new database.

Result: the page was missing content. What was going on was that the
route object ended up listening to the event multiple times, causing
the error. This now explicitly cleans up and re-assigns the listeners
for this scenario.

Closes COUCHDB-2503


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/7e99366c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/7e99366c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/7e99366c

Branch: refs/heads/master
Commit: 7e99366c46dcda47f40071508414910c4438cd02
Parents: cfdc7f9
Author: Benjamin Keen <ben.keen@gmail.com>
Authored: Wed Dec 17 13:03:46 2014 -0800
Committer: Benjamin Keen <ben.keen@gmail.com>
Committed: Thu Dec 18 10:07:05 2014 -0800

----------------------------------------------------------------------
  app/addons/documents/routes-documents.js | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/7e99366c/app/addons/documents/routes-documents.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-documents.js b/app/addons/documents/routes-documents.js
index f38e06f..7c02bba 100644
--- a/app/addons/documents/routes-documents.js
+++ b/app/addons/documents/routes-documents.js
@@ -15,7 +15,6 @@ define([
    "api",

    // Modules
- //views
    "addons/documents/views",
    "addons/documents/views-changes",
    "addons/documents/views-index",
@@ -93,7 +92,7 @@ function(app, FauxtonAPI, Documents, Changes, Index, DocEditor, Databases, Resou

      initialize: function (route, masterLayout, options) {
        this.initViews(options[0]);
- this.listenTo(FauxtonAPI.Events, 'lookaheadTray:update', this.onSelectDatabase);
+ this.listenToLookaheadTray();
      },

      establish: function () {
@@ -146,9 +145,18 @@ function(app, FauxtonAPI, Documents, Changes, Index, DocEditor, Databases, Resou
      onSelectDatabase: function (dbName) {
        this.cleanup();
        this.initViews(dbName);
+
        FauxtonAPI.navigate('/database/' + app.utils.safeURLName(dbName) + '/_all_docs', {
          trigger: true
        });
+
+ // we need to start listening again because cleanup() removed the listener, but in this case
+ // initialize() doesn't fire to re-set up the listener
+ this.listenToLookaheadTray();
+ },
+
+ listenToLookaheadTray: function () {
+ this.listenTo(FauxtonAPI.Events, 'lookaheadTray:update', this.onSelectDatabase);
      },

      setUpDropdown: function() {
@@ -214,7 +222,7 @@ function(app, FauxtonAPI, Documents, Changes, Index, DocEditor, Databases, Resou
        this.apiUrl = [designDocInfo.url('apiurl'), designDocInfo.documentation()];
      },

- tempFn: function(databaseName, ddoc, fn){
+ tempFn: function(databaseName, ddoc, fn){
        this.setView("#dashboard-upper-content", new Documents.Views.temp({}));
        this.crumbs = function () {
          return [
@@ -609,6 +617,9 @@ function(app, FauxtonAPI, Documents, Changes, Index, DocEditor, Databases, Resou
        if (this.footer) {
          this.removeView('#footer');
        }
+
+ // we're no longer interested in listening to the lookahead tray event on this route object
+ this.stopListening(FauxtonAPI.Events, 'lookaheadTray:update', this.onSelectDatabase);
      }

    });

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categoriescouchdb
postedDec 18, '14 at 6:08p
activeDec 18, '14 at 6:08p
posts1
users1
websitecouchdb.apache.org
irc#couchdb

1 user in discussion

Benkeen: 1 post

People

Translate

site design / logo © 2021 Grokbase