diff --git a/hs/behaviors/add-todo._hs b/hs/behaviors/add-todo._hs index 931d42a..0cc7845 100644 --- a/hs/behaviors/add-todo._hs +++ b/hs/behaviors/add-todo._hs @@ -1,19 +1,18 @@ behavior AddTodo on load send focus to me - on focus - if $focus === undefined - my.focus() - set $isFocus to 'true' + on focus + if $focus === undefined + my.focus() + set $isFocus to 'true' + end + on blur set $isFocus to undefined + on keyup[keyCode==13] + if $todo + htmx.ajax('GET', `/add-todo?title=${my.value}`, {target:'.todo-list', swap:'beforeend'}) + set my value to '' + else + htmx.ajax('GET', `/add-todo?title=${my.value}`, {target:'.header', swap:'beforeend'}) + set my value to '' end - on blur set $isFocus to undefined - on keyup[keyCode==13] - if $todo - htmx.ajax('GET', `/add-todo?title=${my.value}`, {target:'.todo-list', swap:'beforeend'}) - set my value to '' - else - htmx.ajax('GET', `/add-todo?title=${my.value}`, {target:'.header', swap:'beforeend'}) - set my value to '' - end - send toggleMain to - send toggleFooter to -end \ No newline at end of file + send toggleMain to + send toggleFooter to \ No newline at end of file diff --git a/hs/behaviors/toggle-show._hs b/hs/behaviors/toggle-show._hs index 299b544..6626577 100644 --- a/hs/behaviors/toggle-show._hs +++ b/hs/behaviors/toggle-show._hs @@ -30,7 +30,7 @@ behavior ToggleShow -- loop through the JSON for todo in it -- check if the element exist in the current DOM, add if none - -- placement is decided according to order if there"s an element + -- placement is decided according to order if there's an element -- with higher than the current todo swap as "beforebegin" for el in $todo.children if parseInt(el.id.slice(5)) > todo.id and document.getElementById(`todo-${todo.id}`) === null