Skip to content

Commit

Permalink
Enter (submit) when editing an item ends the edit.
Browse files Browse the repository at this point in the history
  • Loading branch information
absoludity committed Aug 14, 2012
1 parent aa54820 commit 39c39e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion labs/architecture-examples/derbyjs/src/todos/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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"

This comment has been minimized.

Copy link
@sindresorhus

sindresorhus Aug 14, 2012

Use .nodeName

target.firstChild.blur()
item = model.at(target)
item.set('_editing', false)
text = item.get('text').trim()
if not text
Expand Down
2 changes: 2 additions & 0 deletions labs/architecture-examples/derbyjs/views/todos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ <h1>todos</h1>
<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>
Expand Down

0 comments on commit 39c39e2

Please sign in to comment.