Skip to content

Commit

Permalink
Debug Container rendering - make sure ContainerView renders once, and…
Browse files Browse the repository at this point in the history
… before any other view; debug .editable double-syncing using listenTo('change:attr_only')
  • Loading branch information
fkotsian committed May 28, 2014
1 parent 0ad28a8 commit 16f985c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 38 deletions.
52 changes: 17 additions & 35 deletions app/assets/javascripts/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -15,41 +15,28 @@ 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({
collection: Asana.projects
});
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
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/views/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/items/_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/lists/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down

0 comments on commit 16f985c

Please sign in to comment.