Created
June 5, 2015 03:36
-
-
Save KoryNunn/6fe046323a1077908c5e to your computer and use it in GitHub Desktop.
Components talk
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 fastn = require('fastn')({ | |
| _generic: require('fastn/genericComponent'), | |
| list: require('fastn/listComponent'), | |
| text: require('fastn/textComponent') | |
| }); | |
| window.data = { | |
| foo:'bar', | |
| name: 'ROOT', | |
| children: [ | |
| { | |
| name: 'bob', | |
| children: [ | |
| { name: 'mary', children: [] } | |
| ], | |
| } | |
| ] | |
| }; | |
| var createChildrenList = function(){ | |
| return fastn('div', | |
| 'Name', fastn.binding('name'), | |
| 'Thing', | |
| fastn('input', { | |
| value: fastn.binding('foo').attach(window.data), | |
| onkeyup: 'value:value' | |
| }), | |
| fastn('list', { | |
| tagName: 'ul', | |
| items: fastn.binding('children'), | |
| template: function(model){ | |
| return createChildrenList().binding('item'); | |
| } | |
| }) | |
| ); | |
| } | |
| var thing = fastn('list', {foo:'bar'}, | |
| createChildrenList() | |
| ); | |
| thing.attach(window.data); | |
| thing.render(); | |
| window.addEventListener('load', function(){ | |
| document.body.appendChild(thing.element); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment