Created
February 7, 2013 08:57
-
-
Save piuccio/4729665 to your computer and use it in GitHub Desktop.
hashspace Event listeners on scope objects
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
// Click on the fruit name toggles the fruit's edible property |
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 Fruit = function (name) { | |
this.name = name; | |
this.edible = true; | |
}; | |
Fruit.prototype.spoil = function () { | |
json.set(this, "edible", !this.edible); | |
} | |
var basket = [ | |
new Fruit("Banana"), | |
new Fruit("Kiwi"), | |
new Fruit("Orange") | |
]; | |
# template shopping(basket) | |
This is what you have in your basket <br/> | |
# foreach fruit in basket | |
<span onclick="{fruit.spoil()}">{fruit.name}</span> | |
# if fruit.edible | |
is good | |
# else | |
<strike>is bad</strike> | |
# /if | |
<br /> | |
# /foreach | |
# /template | |
display(shopping, [basket]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment