Skip to content

Instantly share code, notes, and snippets.

@piuccio
Created February 7, 2013 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piuccio/4729665 to your computer and use it in GitHub Desktop.
Save piuccio/4729665 to your computer and use it in GitHub Desktop.
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