Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fix #7

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading