Last active
April 19, 2019 20:31
-
-
Save mardix/5da94dd5ce637ce2e6a422e0113b654a to your computer and use it in GitHub Desktop.
relift-example-todo.html
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
<div> | |
<div class="column" id="todoAppWidget" style="display:none"> | |
<div class="center"> | |
<div>Enter your item</div> | |
<input type="text" id="todo-input" /> | |
<button @click="add">Save</button> | |
</div> | |
<div> | |
<ul> | |
<li r-for="item,i in this.todos"> | |
${item} <a @click="remove" data-index="${i}">Remove</a> | |
</li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<script type="module"> | |
import reLift from '../src/index.js'; | |
reLift({ | |
el: '#todoAppWidget', | |
data: { | |
todos: [ | |
'Take dog to school', | |
'Eat dinner', | |
'Code more' | |
], | |
}, | |
add() { | |
const input = this.el.querySelector('#todo-input'); | |
if (input.value) { | |
this.data.todos.push(input.value); | |
} | |
}, | |
remove(e) { | |
const index = parseInt(e.target.getAttribute('data-index')); | |
this.data.todos.splice(index, 1); | |
}, | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment