Permalink
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (29 sloc) 703 Bytes
<style>
body {
padding: 50px;
font: 14px Helvetica, Arial;
}
label {
display: block;
clear: both;
}
</style>
<h1>Editable</h1>
<p>Click any of the items below to edit inline:</p>
<ul>
<li data-editable='/item/1'>One</li>
<li data-editable='/item/2'>Two</li>
<li data-editable='/item/3'>Three</li>
</ul>
<script src="./reactive.js"></script>
<script>
var reactive = require('reactive');
var view = reactive(document.querySelector('ul'));
view.bind('data-editable', function(el, url){
el.setAttribute('contenteditable', 'true');
el.onblur = function(){
var str = el.textContent;
console.log('save "%s" to %s', str, url);
};
});
</script>