Skip to content

Instantly share code, notes, and snippets.

@piuccio piuccio/console.js
Created Feb 7, 2013

Embed
What would you like to do?
hashspace Event listeners on scope objects
// Click on the fruit name toggles the fruit's edible property
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
You can’t perform that action at this time.