Backbone fixes

This commit is contained in:
Boris Yankov
2012-10-22 10:59:42 +03:00
parent 9ce42c577f
commit dd5444a11b
2 changed files with 27 additions and 21 deletions

View File

@@ -142,6 +142,8 @@ declare module Backbone {
navigate(fragment, options? );
}
export var history: History;
export class History {
start(options? );
}

View File

@@ -24,33 +24,33 @@ object.off();
//////////////////////////////////////////////////////
var Sidebar = Backbone.Model.extend({
promptColor: function() {
var cssColor = prompt("Please enter a CSS color:");
this.set({color: cssColor});
}
promptColor: function () {
var cssColor = prompt("Please enter a CSS color:");
this.set({ color: cssColor });
}
});
var sidebar = new Sidebar();
sidebar.on('change:color', (model, color) => $('#sidebar').css({background: color}));
sidebar.set({color: 'white'});
sidebar.on('change:color', (model, color) => $('#sidebar').css({ background: color }));
sidebar.set({ color: 'white' });
sidebar.promptColor();
////////
var Note = Backbone.Model.extend({
initialize: () => { },
author: () => { },
coordinates: () => { },
allowedToEdit: (account) => {
return true;
}
initialize: () => { },
author: () => { },
coordinates: () => { },
allowedToEdit: (account) => {
return true;
}
});
var PrivateNote = Note.extend({
allowedToEdit: function(account) {
return account.owns(this);
}
allowedToEdit: function (account) {
return account.owns(this);
}
});
@@ -58,14 +58,14 @@ var PrivateNote = Note.extend({
//////////
var note = Backbone.Model.extend({
set: function(attributes, options) {
Backbone.Model.prototype.set.call(this, attributes, options);
}
set: function (attributes, options) {
Backbone.Model.prototype.set.call(this, attributes, options);
}
});
note.get("title")
note.set({title: "March 20", content: "In his eyes she eclipses..."});
note.set({ title: "March 20", content: "In his eyes she eclipses..." });
note.set("title", "A Scandal in Bohemia");
@@ -85,5 +85,9 @@ class EmployeeCollection extends Backbone.Collection {
url: string = "../api/employees";
model = Employee;
findByName(key) {}
}
findByName(key) { }
}
//////////
Backbone.history.start();