From 16f985c510cffd077189c547c223e66ca8ca63a9 Mon Sep 17 00:00:00 2001 From: Frank Kotsianas Date: Wed, 28 May 2014 14:43:51 -0700 Subject: [PATCH] Debug Container rendering - make sure ContainerView renders once, and before any other view; debug .editable double-syncing using listenTo('change:attr_only') --- app/assets/javascripts/routers/router.js | 52 +++++++-------------- app/assets/javascripts/views/container.js | 1 - app/assets/javascripts/views/items/_item.js | 2 +- app/assets/javascripts/views/lists/show.js | 2 +- 4 files changed, 19 insertions(+), 38 deletions(-) diff --git a/app/assets/javascripts/routers/router.js b/app/assets/javascripts/routers/router.js index 64b2f70..e340183 100644 --- a/app/assets/javascripts/routers/router.js +++ b/app/assets/javascripts/routers/router.js @@ -2,7 +2,7 @@ Asana.Routers.Router = Backbone.Router.extend({ initialize: function (options) { this.$rootEl = options.$rootEl; // perhaps use a $projectEl, $listEl, and $itemEl (in same vein as NewsReader sidebar) - // this.appContainer(); + this.renderAppContainer(); }, routes: { @@ -15,7 +15,7 @@ Asana.Routers.Router = Backbone.Router.extend({ 'lists/:list_id/items/:id': 'itemShow', }, - renderAppContainer: function(callback) { + renderAppContainer: function() { // our base collection = Asana.projects if(!this._appContainer) { this._appContainer = new Asana.Views.Container({ @@ -23,33 +23,20 @@ Asana.Routers.Router = Backbone.Router.extend({ }); this.swapView(this._appContainer); } - - // Asana.projects.fetch({ - // success: function() { - callback(); - // } - // }); }, - projectShow: function(id) { - // getOrFetch our project from projects collection - - - }, + projectShow: function(id) {}, dashboard: function() { - this.renderAppContainer(); + // maintain rendered AppContainer view }, listShow: function(projectId, id) { - var that = this; - this.renderAppContainer(function() { - var list = Asana.projects.getOrFetch(projectId).lists().getOrFetch(id); - var newListView = new Asana.Views.ListShow({ - model: list - }); - that.swapPaneView('#list-pane', newListView); - }) + var list = Asana.projects.getOrFetch(projectId).lists().getOrFetch(id); + var newListView = new Asana.Views.ListShow({ + model: list + }); + this.swapPaneView('#list-pane', newListView); /*on refactor: - remove ContainerView @@ -64,19 +51,14 @@ Asana.Routers.Router = Backbone.Router.extend({ }, itemShow: function(listId, id) { - var that = this; - this.renderAppContainer(function() { - console.log('in itemsShow') - var list = Asana.projects.findList(listId); - var item = list.items().getOrFetch(id); - // debugger - var newItemView = new Asana.Views.ItemShow({ - model: item, - projectId: list.get('project_id') - }); - that.swapPaneView('#item-pane', newItemView); - }) - + console.log('in itemsShow'); + var list = Asana.projects.findList(listId); + var item = list.items().getOrFetch(id); + var newItemView = new Asana.Views.ItemShow({ + model: item, + projectId: list.get('project_id') + }); + this.swapPaneView('#item-pane', newItemView); }, swapPaneView: function(paneSelector, newView) { diff --git a/app/assets/javascripts/views/container.js b/app/assets/javascripts/views/container.js index 4feeb63..67733ac 100644 --- a/app/assets/javascripts/views/container.js +++ b/app/assets/javascripts/views/container.js @@ -18,7 +18,6 @@ Asana.Views.Container = Backbone.CompositeView.extend({ }, setupPage: function() { - alert('setting up page') var projectsPane = new Asana.Views.ProjectsIndex({ collection: this.collection }); diff --git a/app/assets/javascripts/views/items/_item.js b/app/assets/javascripts/views/items/_item.js index c642148..aed0b8c 100644 --- a/app/assets/javascripts/views/items/_item.js +++ b/app/assets/javascripts/views/items/_item.js @@ -4,7 +4,7 @@ Asana.Views._Item = Backbone.View.extend({ initialize: function(options) { this.project_id = options.project_id; - this.listenTo(this.model, 'sync change', this.render); + this.listenTo(this.model, 'sync change:title', this.render); }, events: { diff --git a/app/assets/javascripts/views/lists/show.js b/app/assets/javascripts/views/lists/show.js index 6049f74..202615d 100644 --- a/app/assets/javascripts/views/lists/show.js +++ b/app/assets/javascripts/views/lists/show.js @@ -37,7 +37,7 @@ Asana.Views.ListShow = Backbone.CompositeView.extend({ that.addSubview('#list-items', _blankItem.render()); } - this.listenTo(this.model, 'sync change', this.render); + this.listenTo(this.model, 'sync change:title change:description', this.render); // this.listenTo(this.subviews(), 'add remove', this.render); //don't need yet },