Skip to content

Commit

Permalink
works; need to improve design greatly
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrimpel committed Dec 17, 2011
1 parent d4df49d commit 8079618
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
2 changes: 0 additions & 2 deletions examples/todos-requirejs-2/collections/TodoList.js
Expand Up @@ -27,8 +27,6 @@ define(function () {
// GUID in the database. This generates the next order number for new items.
nextOrder: function() {
console.log('nextOrder');
console.log(this.last().get('order'));


if (!this.length) return 1;
return this.last().get('order') + 1;
Expand Down
47 changes: 25 additions & 22 deletions examples/todos-requirejs-2/models/Todo.js
@@ -1,29 +1,32 @@
define(function () {
'use strict';

var module = {}, Todo;

// Todo Model
// ----------

// Our basic **Todo** model has `text`, `order`, and `done` attributes.
Todo = Backbone.Model.extend({

// Default attributes for a todo item.
defaults: {
done: false
},

// Toggle the `done` state of this todo item.
toggle: function() {
console.log('toggle');
this.save({done: !this.get("done")});
}
var module = {};

module.create = function (params) {
// Todo Model
// ----------

// Our basic **Todo** model has `text`, `order`, and `done` attributes.
var Todo = Backbone.Model.extend({

// Default attributes for a todo item.
defaults: function() {
return {
done: false,
order: params.collection.nextOrder()
};
},

// Toggle the `done` state of this todo item.
toggle: function() {
console.log('toggle');
this.save({done: !this.get("done")});
}

});

module.create = function (properties) {
return new Todo(properties);
});

return Todo;
};

return module;
Expand Down
8 changes: 5 additions & 3 deletions examples/todos-requirejs-2/todos.js
@@ -1,12 +1,14 @@
// Load the application once the DOM is ready, using `jQuery.ready`:
define (['collections/TodoList', 'views/App'], function (todoCollection, appView) {
define (['collections/TodoList', 'views/App', 'models/Todo'], function (todoCollection, appView, todoModel) {
'use strict';

var module = {};

module.init = function () {
var collection = todoCollection.create();

var collection = todoCollection.create(),
model = todoModel.create({ 'collection' : collection });

collection.model = model;
return appView.create({ 'collection' : collection });
};

Expand Down

0 comments on commit 8079618

Please sign in to comment.