Created
September 3, 2013 11:03
-
-
Save maetl/6422464 to your computer and use it in GitHub Desktop.
Mozart models in raw JS... can they work?
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
| var Geography; | |
| window.Geography = this.Geography = Geography = {}; | |
| Geography.Country = Mozart.Model.create({ | |
| modelName: "Country" | |
| }); | |
| Geography.Country.attributes({ | |
| name: "string", | |
| code: "string" | |
| }); | |
| Geography.State = Mozart.Model.create({ | |
| modelName: "State" | |
| }); | |
| Geography.State.attributes({ | |
| name: "string", | |
| country_id: "integer", | |
| code: "string" | |
| }); | |
| Geography.Country.hasMany(Geography.State, "states"); | |
| Geography.Country.ajax({ | |
| url: "/admin/countries" | |
| }); | |
| Geography.State.ajax({ | |
| url: "/admin/states" | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment