Skip to content

Instantly share code, notes, and snippets.



Created Feb 7, 2013
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) { = 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()}">{}</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