Created
June 28, 2012 05:29
-
-
Save rightson/3009291 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title> Learning about Bacjbone.js </title> | |
</head> | |
<body> | |
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script> | |
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script> | |
<script type="text/javascript"> | |
Person = Backbone.Model.extend({ | |
initialize: function() { | |
console.log("hello world!"); | |
this.bind("change:name", function() { | |
alert('change!'); | |
console.log(person.get('name')); | |
}); | |
}, | |
defaults: { | |
name: "Scott", | |
height: "unknown" | |
} | |
}); | |
var person = new Person(); | |
console.log(person.get('name')); | |
person.set({name: "Steven"}); | |
console.log(person.get('name')); | |
</script> | |
</body> | |
</html> | |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment