Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Backbone 1.2+ #17

Merged
merged 3 commits into from
Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions en/appendix/getting_started/tutorial/todo_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ var initialData = {
]
};


var App = new Marionette.Application({
onStart: function(options) {
var todo = new TodoView(options);
var todo = new TodoView({
collection: new Backbone.Collection(options.initialData.items),
model: new ToDoModel()
});
todo.render();
todo.triggerMethod('show');
}
Expand Down Expand Up @@ -61,14 +65,6 @@ var Layout = Marionette.LayoutView.extend({
add: 'itemAdded'
},

initialize: function() {
this.collection = new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]);
this.model = new ToDoModel();
},

onShow: function() {
var formView = new FormView({model: this.model});
var listView = new ListView({collection: this.collection});
Expand Down
37 changes: 18 additions & 19 deletions en/getting_started/tutorial/firstview.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var HelloWorld = Marionette.LayoutView.extend({ // 2
});

var hello = new HelloWorld(); // 5

hello.render(); // 6
```

Expand Down Expand Up @@ -66,19 +67,18 @@ var Marionette = require('backbone.marionette');

var TodoList = Marionette.LayoutView.extend({
el: '#app-hook',
template: require('./templates/layout.html'),

initialize: function() {
this.model = new Backbone.Model({
items: [
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]
});
}
template: require('./templates/layout.html')
});

var todo = new TodoList({
model: new Backbone.Model({
items: [
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]
})
});

var todo = new TodoList();
todo.render();
```

Expand Down Expand Up @@ -126,17 +126,16 @@ var TodoList = Marionette.CollectionView.extend({
el: '#app-hook',
tagName: 'ul',

childView: ToDo,
childView: ToDo
});

initialize: function() {
this.collection = new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]);
}
var todo = new TodoList({
collection: new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
])
});

var todo = new TodoList();
todo.render();
```

Expand Down
22 changes: 6 additions & 16 deletions en/getting_started/tutorial/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var ToDoModel = require('./models/todo');

var ToDo = Marionette.LayoutView.extend({
tagName: 'li',
template: './templates/todoitem.html'
template: require('./templates/todoitem.html')
});


Expand Down Expand Up @@ -62,11 +62,6 @@ var TodoList = Marionette.CompositeView.extend({
change: 'render'
},

initialize: function() {
this.collection = new Backbone.Collection(this.getOption('initialData'));
this.model = new ToDoModel();
},

onAddTodoItem: function() {
this.model.set({
assignee: this.ui.assignee.val(),
Expand Down Expand Up @@ -116,7 +111,10 @@ var initialData = {

var App = new Marionette.Application({
onStart: function(options) {
var todo = new TodoView(options);
var todo = new TodoView({
collection: new Backbone.Collection(this.getOption('initialData')),
model: new ToDoModel()
});
todo.render();
todo.triggerMethod('show');
}
Expand Down Expand Up @@ -237,14 +235,6 @@ var Layout = Marionette.LayoutView.extend({
add: 'itemAdded'
},

initialize: function() {
this.collection = new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]);
this.model = new ToDoModel();
},

onShow: function() {
var formView = new FormView({model: this.model});
var listView = new ListView({collection: this.collection});
Expand All @@ -269,7 +259,7 @@ var Layout = Marionette.LayoutView.extend({
text: ''
});
}
})
});
```


Expand Down
71 changes: 33 additions & 38 deletions en/getting_started/tutorial/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var Marionette = require('backbone.marionette');

var ToDo = Marionette.LayoutView.extend({
tagName: 'li',
template: './templates/todoitem.html'
template: require('./templates/todoitem.html')
});


Expand All @@ -27,17 +27,16 @@ var TodoList = Marionette.CompositeView.extend({
template: require('./templates/todolist.html'),

childView: ToDo,
childViewContainer: 'ul',
childViewContainer: 'ul'
});

initialize: function() {
this.collection = new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]);
}
var todo = new TodoList({
collection: new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
])
});

var todo = new TodoList();
todo.render();
```

Expand Down Expand Up @@ -79,7 +78,7 @@ var Marionette = require('backbone.marionette');

var ToDo = Marionette.LayoutView.extend({
tagName: 'li',
template: './templates/todoitem.html'
template: require('./templates/todoitem.html')
});


Expand All @@ -104,13 +103,6 @@ var TodoList = Marionette.CompositeView.extend({
add: 'itemAdded'
},

initialize: function() {
this.collection = new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]);
},

onAddTodoItem: function() { // 4
this.collection.add({
assignee: this.ui.assignee.val(), // 5
Expand All @@ -124,7 +116,12 @@ var TodoList = Marionette.CompositeView.extend({
}
});

var todo = new TodoList();
var todo = new TodoList({
collection: new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
])
});
todo.render();
```

Expand Down Expand Up @@ -216,7 +213,7 @@ var ToDoModel = require('./models/todo');

var ToDo = Marionette.LayoutView.extend({
tagName: 'li',
template: './templates/todoitem.html'
template: require('./templates/todoitem.html')
});


Expand All @@ -241,14 +238,6 @@ var TodoList = Marionette.CompositeView.extend({
add: 'itemAdded'
},

initialize: function() {
this.collection = new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]);
this.model = new ToDoModel();
},

onAddTodoItem: function() {
this.model.set({
assignee: this.ui.assignee.val(),
Expand All @@ -270,7 +259,14 @@ var TodoList = Marionette.CompositeView.extend({
}
});

var todo = new TodoList();
var todo = new TodoList({
collection: new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]),
model: new ToDoModel()
});

todo.render();
```

Expand Down Expand Up @@ -316,7 +312,7 @@ var ToDoModel = require('./models/todo');

var ToDo = Marionette.LayoutView.extend({
tagName: 'li',
template: './templates/todoitem.html'
template: require('./templates/todoitem.html')
});


Expand Down Expand Up @@ -345,14 +341,6 @@ var TodoList = Marionette.CompositeView.extend({
change: 'render'
},

initialize: function() {
this.collection = new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]);
this.model = new ToDoModel();
},

onAddTodoItem: function() {
this.model.set({
assignee: this.ui.assignee.val(),
Expand All @@ -371,7 +359,14 @@ var TodoList = Marionette.CompositeView.extend({
}
});

var todo = new TodoList();
var todo = new TodoList({
collection: new Backbone.Collection([
{assignee: 'Scott', text: 'Write a book about Marionette'},
{assignee: 'Andrew', text: 'Do some coding'}
]),
model: new ToDoModel()
});

todo.render();
```

Expand Down