Created
February 10, 2012 16:53
-
-
Save ktusznio/1790846 to your computer and use it in GitHub Desktop.
batman.js checkbox 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test App</title> | |
<script type="text/javascript" src="../lib/es5-shim.js"></script> | |
<script type="text/javascript" src="../lib/batman.js"></script> | |
<script type="text/javascript" src="../lib/batman.solo.js"></script> | |
<script type="text/javascript" src="../lib/extras/batman.rails.js"></script> | |
<script type="text/javascript" src="../lib/coffee-script.js"></script> | |
</head> | |
<body> | |
<ul> | |
<li data-foreach-contact="controllers.app.contacts"> | |
<label class="checkbox"> | |
<input type="checkbox" data-bind="contact.isShowing"> | |
<span data-bind="contact.name"></span> | |
</label> | |
</li> | |
</ul> | |
<div data-foreach-contact="controllers.app.contacts" data-showif="contact.isShowing" data-bind="contact.name"></div> | |
<script type="text/coffeescript"> | |
class App extends Batman.App | |
@global yes | |
@root 'app#index' | |
class App.Contact extends Batman.Model | |
class App.AppController extends Batman.Controller | |
index: -> | |
c1 = new App.Contact(name: 'a') | |
c2 = new App.Contact(name: 'b') | |
@set 'contacts', new Batman.Set(c1, c2) | |
@render false | |
App.run() | |
</script> | |
</body> | |
</html> |
isShowing isn't set initially, but it's bound to the checkbox which sets it
to true when checked.
…On Tuesday, March 13, 2012, Vincent Siebert < ***@***.***> wrote:
I'm not sure how this works. Where does the Contact model get the
isShowing property from? Can't see it being set anywhere, or am I missing
something?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1790846
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure how this works. Where does the Contact model get the isShowing property from? Can't see it being set anywhere, or am I missing something?