Skip to content

Commit

Permalink
Backbone fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
borisyankov committed Oct 22, 2012
1 parent 9ce42c5 commit dd5444a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Definitions/backbone-0.9.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ declare module Backbone {
navigate(fragment, options? );
}

export var history: History;

export class History {
start(options? );
}
Expand Down
46 changes: 25 additions & 21 deletions Tests/backbone-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,48 @@ 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);
}

});


//////////

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");

Expand All @@ -85,5 +85,9 @@ class EmployeeCollection extends Backbone.Collection {

url: string = "../api/employees";
model = Employee;
findByName(key) {}
}
findByName(key) { }
}

//////////

Backbone.history.start();

0 comments on commit dd5444a

Please sign in to comment.