Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shahrul committed Jan 29, 2024
1 parent e0f1ba6 commit fbf823c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 15 additions & 16 deletions hs/behaviors/add-todo._hs
Original file line number Diff line number Diff line change
@@ -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 <section.todoapp/>
send toggleFooter to <section.todoapp/>
end
send toggleMain to <section.todoapp/>
send toggleFooter to <section.todoapp/>
2 changes: 1 addition & 1 deletion hs/behaviors/toggle-show._hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fbf823c

Please sign in to comment.