Permalink
Browse files

Enter (submit) when editing an item ends the edit.

  • Loading branch information...
1 parent aa54820 commit 39c39e266a8547307395ae11750b8f7918ef7d04 @absoludity committed Aug 14, 2012
@@ -84,7 +84,10 @@ ready (model) ->
group.set('select_all', false)
exports.endEdit = (e) ->
- item = model.at(e.target)
+ target = e.target
+ if target.tagName == "FORM"
+ target.firstChild.blur()
+ item = model.at(target)
item.set('_editing', false)
text = item.get('text').trim()
if not text
@@ -37,7 +37,9 @@
<li data-id={{id}} class="{#if .completed}completed{else}active{/}{#if ._editing} editing{/}">
<div>
<input class="toggle" type="checkbox" checked={.completed}>
+ <form x-bind=submit:endEdit>
<input class="text" x-bind="focus:startEdit, blur:endEdit" value="{.text}">
+ </form>
<button class="destroy" x-bind=click:del></button>
</div>
</li>

0 comments on commit 39c39e2

Please sign in to comment.