/examples/todos-requirejs-4/models/todo.js
JavaScript | 34 lines | 19 code | 10 blank | 5 comment | 0 complexity | 1bca8644019b7880c57c50cd908f179a MD5 | raw file
- // Todo Model
- // ----------
- define(function () {
- 'use strict';
-
- var module = {};
-
- module.create = function (properties) {
-
-
- // 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: properties.collection.nextOrder()
- };
- },
-
- // Toggle the 'done' state of this todo item.
- toggle: function () {
- this.save({done: !this.get("done")});
- }
-
- });
-
- return Todo;
- };
-
- return module;
- });