https://github.com/nichoth/vdom-crud-li
Editable list item
https://github.com/nichoth/vdom-crud-li
Last synced: about 2 months ago
JSON representation
Editable list item
- Host: GitHub
- URL: https://github.com/nichoth/vdom-crud-li
- Owner: nichoth
- Created: 2016-01-11T20:02:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-15T19:31:32.000Z (over 10 years ago)
- Last Synced: 2025-03-03T06:12:34.612Z (over 1 year ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# vdom crud li
Editable list item for virtual doms.
[demo](http://hallowed-letters.surge.sh/vdom-crud-li)
## install
$ npm install vdom-crud-li
## example
```js
var vdom = require('virtual-dom');
var h = vdom.h;
var Item = require('../CrudListItem.js');
var data = [
{name: 'item 1'},
{name: 'item 2'}
];
var state = Item({
value: data[0].name,
textNodeFn: function(val) {
return h('a', { href: '/' }, [val]);
},
deleteFn: console.log.bind(console, 'delete item 1'),
saveFn: function(value, done) {
console.log('save: ' + value);
done();
}
});
var loop = require('main-loop')( state(), Item.render.bind(null, h), vdom );
state(loop.update);
document.getElementById('content').appendChild(loop.target);
```