Skip to content

Instantly share code, notes, and snippets.

@ktusznio
Created February 10, 2012 16:53
Show Gist options
  • Save ktusznio/1790846 to your computer and use it in GitHub Desktop.
Save ktusznio/1790846 to your computer and use it in GitHub Desktop.
batman.js checkbox example
<!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>
@luxerama
Copy link

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?

@ktusznio
Copy link
Author

ktusznio commented Mar 13, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment