Created
August 1, 2012 15:25
-
-
Save michaelgodshall/3227795 to your computer and use it in GitHub Desktop.
Batman.js Example
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 characters
class App extends Batman.App | |
@root 'students#index' | |
# Make App available in the global namespace so it can be used | |
# as a namespace and bound to in views. | |
window.App = App |
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 characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title></title> | |
<script src="/batman/coffee-script.js" type="text/javascript"></script> | |
<script src="/batman/es5-shim.js" type="text/javascript"></script> | |
<script src="/batman/dist/batman.js" type="text/javascript"></script> | |
<script src="app.js" type="text/javascript"></script> | |
<script src="controllers/application_controller.js" type="text/javascript"></script> | |
<script src="controllers/students.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<div data-yield="main"></div> | |
<div data-defineview="students/index"> | |
<button data-event-click="create"> | |
New Student | |
</button> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
App.run(); | |
</script> | |
</body> | |
</html> |
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 characters
class App.Student extends Batman.Model | |
@resourceName: 'student' | |
@storageKey: 'students' | |
@persist Batman.LocalStorage | |
@encode 'first_name', 'last_name', 'email' |
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 characters
class App.StudentsController extends App.ApplicationController | |
routingKey: 'students' | |
index: (params) -> | |
console.log 'Ready!' | |
create: (params) -> | |
newStudent = new App.Student(first_name: 'First', last_name: 'Last', email: '') | |
newStudent.save() | |
console.log 'Created', newStudent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment