Created
July 15, 2012 04:55
Revisions
-
rightson revised this gist
Jul 16, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Learning About Backbone.js AJAX</title> </head> <body> -
rightson revised this gist
Jul 15, 2012 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -17,13 +17,13 @@ var Person = Backbone.Model.extend({ initialize: function() { this.on('all', function(e) { console.log(this.get('name') + " event: " + e); }); }, defaults: { name: 'undefined', age: 'undefined' }, urlRoot: "/examples/backbonejs-ajax/backbone.php", url: function() { var base = this.urlRoot || (this.collection && this.collection.url) || "/"; if (this.isNew()) return base; @@ -43,10 +43,10 @@ var People = Backbone.Collection.extend({ initialize: function() { this.on('all', function(e) { console.log("People event: " + e); }); }, model: Person, url: "/examples/backbonejs-ajax/backbone.php" }); var people = new People(); @@ -55,4 +55,4 @@ people.create({id:6, name:"Chuck Norris", age:72}); </script> </body> </html> -
rightson created this gist
Jul 15, 2012 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Learning About Backbone.js Routers</title> </head> <body> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="http://documentcloud.github.com/underscore/underscore-min.js"></script> <script type="text/javascript" src="http://documentcloud.github.com/backbone/backbone-min.js"></script> <script type="text/javascript"> Backbone.emulateHTTP = true; Backbone.emulateJSON = true; var Person = Backbone.Model.extend({ initialize: function() { this.on('all', function(e) { alert(this.get('name') + " event: " + e); }); }, defaults: { name: 'undefined', age: 'undefined' }, urlRoot: "/examples/backbone.php", url: function() { var base = this.urlRoot || (this.collection && this.collection.url) || "/"; if (this.isNew()) return base; return base + "?id=" + encodeURIComponent(this.id); } }); var person = new Person({id:1}); person.fetch(); person = new Person({name:"Joe Zim", age:23}); person.save(); person = new Person({id:1, name:"Joe Zim", age:23}); person.save(); person.destroy(); var People = Backbone.Collection.extend({ initialize: function() { this.on('all', function(e) { alert("People event: " + e); }); }, model: Person, url: "/examples/backbone.php" }); var people = new People(); people.fetch(); people.create({name:"Joe Zim", age:23}); people.create({id:6, name:"Chuck Norris", age:72}); </script> </body> </html>