JSFiddle - React, Tailwind, and code Playground
JavaScript
// An Example of Backbone application from Nikita Larionov
// This demo of todo application focused on projects
// contacts: [email protected], skype: tolarionov
// 07.02.2014
// Load application once the DOM is ready, using 'jQuery.ready':
$(function(){
window.todom = window.todom || {
Routers: {},
Collections: {},
Models: {},
Views: {}
};
// Project Model
// -------------
// Our basic ** Project Model ** has title, description, done, order, author, id attributes
var Project = Backbone.Model.extend({
defaults: function() {
return {
name: '',
author: '',
id: '',
order: '',
todos: '',
description: ''
}
},
test: function() {
console.log('this is test');
},
setNumberOfTodo: function(num) {
this.set({
todo: num
})
}
});
var Todo = Backbone.Model.extend({
});
var ProjectList = Backbone.Collection.extend({
});
var TodoList = Backbone.Collection.extend({
getProjectTodo: function(id) {
var result = this.where({projectID: id});
_.each(result, function(obj){
console.log(obj.toJSON());
});
return result;
}
});
// Views
// Index
var indexProjectRow = Backbone.View.extend({
});
var indexTodoRow = Backbone.View.extend({
});
var projectListView = Backbone.View.extend({
projectRowTemplate: $('#ProjectListRowTpl'),
initialize: function(projects, todos, models) {
this.projects = projects;
this.todos = todos;
},
el: $('#ProjectListTpl'),
render: function() {
}
});
// The Application
// ---------------
// Top Level UI element
var todoM = Backbone.View.extend({
...