Created
May 7, 2014 18:41
-
-
Save ccummings/c7d95fb6d0e5cdab13fa to your computer and use it in GitHub Desktop.
This file contains 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
<script> | |
can.Component.extend({ | |
tag: "site-app", | |
scope: { | |
define: { | |
type: { | |
value: "fun" | |
}, | |
items: { | |
Value: Site.List, | |
get: function(currentValue){ | |
currentValue.replace( Site.findAll({type: this.attr("type")}) ); | |
return currentValue; | |
} | |
} | |
} | |
} | |
}); | |
</script> | |
<script> | |
<site-app> | |
Link Type: <select can-value="type"> | |
<option value="fun">Fun</option> | |
<option value="educational">Educational</option> | |
<option value="empty">Empty</option> | |
<option value="missing">Missing (404)</option> | |
</select> | |
<table class="table"> | |
<thead> | |
<tr> | |
<td>Name</td><td>URL</td> | |
</tr> | |
</thead> | |
<tbody> | |
{{#if items.isPending}} | |
<tr class="info"><td colspan="2">Loading</td></tr> | |
{{/if}} | |
{{#if items.isResolved}} | |
{{#if items.length}} | |
{{#each items}} | |
<tr> | |
<td>{{name}}</td> <td>{{url}}</td> | |
</tr> | |
{{/each}} | |
{{else}} | |
<tr class="warning"><td colspan="2">No items</td></tr> | |
{{/if}} | |
{{/if}} | |
{{#if items.isRejected}} | |
<tr class="danger"> | |
<td colspan="2">Error: {{items.reason.responseJSON.message}}!</td> | |
</tr> | |
{{/if}} | |
</tbody> | |
</table> | |
</site-app> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment