suppose I have this template:
<script type="text/html" id="list_tpl">
<ul>
{{#list}}
<li><input value="{{ name }}" /><a href="javascript:void(0);">delete</a></li>
{{/list}}
</ul>
</script>
render:
Mustache.to_html(document.getElementById("list_tpl").innerHTML), {
"list": [
{"name": "a1"},
{"name": "a2"},
{"name": "a3"}
]
});
I'd like to bind a event that when the delete
link in each <li>
is clicked, that <li>
gets removed from the DOM.
I know I could bind event after the render is complete, but as the render will happen several times(every time the user click a button), I don't want to bind it every time.
How to do that nicely?