user
09/30/2021, 4:04 PMuser
09/30/2021, 4:05 PMuser
09/30/2021, 4:08 PMuser
09/30/2021, 5:16 PMnarrow-rain-20889
09/30/2021, 6:43 PM.fade-me-in.htmx-settling{
opacity: 0;
}
.fade-me-in {
opacity: 1;
transition: opacity 1s ease-out;
}
.fade-me-out.htmx-swapping {
opacity: 0;
transition: opacity 1s ease-out;
}
My comment template that's being returned from the post call has these classes:
<div id="comment-{{ comment.id }}" class="box fade-me-in fade-me-out">
...
</div>
Button inside the comment that deletes it and works fine:
<button class="delete"
hx-delete="{{ url_for('posts.del_comment', post_id=comment.id) }}"
hx-confirm="Are you sure you wish to delete this comment?"
hx-target="#comment-{{ comment.id }}"
hx-swap="outerHTML swap:1s"></button>
And the form that posts the comment that doesn't work:
<form hx-post="{{ url_for('posts.add_comment', post_id=post.id) }}" hx-swap="afterbegin settle:1s" hx-target="#comments">
...
</form>
When I tried to add fade-me-in class to the #comments div which contains all the comments, the whole thing with all the comments faded out and back in when a new comment was posted, but that's not the desired behavior. It looks like the code is not seeing the new comment's fade-me-in class until after it already shows up on the page.mysterious-toddler-20573
09/30/2021, 9:07 PMcss
.fade-me-in.htmx-settling{
opacity: 0;
}
is going to apply in the settle -> finish phasemysterious-toddler-20573
09/30/2021, 9:08 PMmysterious-toddler-20573
09/30/2021, 9:08 PMmysterious-toddler-20573
09/30/2021, 9:23 PMmysterious-toddler-20573
09/30/2021, 9:23 PMmysterious-toddler-20573
09/30/2021, 9:24 PMmysterious-toddler-20573
09/30/2021, 9:24 PMmysterious-toddler-20573
09/30/2021, 9:24 PMmysterious-toddler-20573
09/30/2021, 9:25 PMmysterious-toddler-20573
09/30/2021, 9:25 PMhtml
<div _="on load transition my opacity to 1">
...
</div>echoing-businessperson-73097
10/01/2021, 1:07 AMmysterious-toddler-20573
10/01/2021, 2:14 AMmysterious-toddler-20573
10/01/2021, 2:14 AMechoing-businessperson-73097
10/01/2021, 8:03 AMcold-lamp-11377
10/01/2021, 9:37 AMcold-lamp-11377
10/01/2021, 9:40 AMmysterious-toddler-20573
10/01/2021, 12:54 PMcold-lamp-11377
10/01/2021, 1:06 PM<script>
htmx.onLoad(async (elt) => {
if (elt.querySelector('#device_details') !== null) {
// Without this check, onLoad would execute this javascript for every htmx load. We only want this
// in case of a device details
let {Device} = await import("{% static 'device_admin/device_mgmt_commands.js' %}")
let {show_toast, getCookie} = await import("{% static 'device_admin/common.js' %}")
const device = new Device("{{ manageddevice.id }}", "{{ manageddevice.androidmanagementname }}")
document.querySelector('#btn_request_logs').addEventListener('click', () => device.request_logs())
}
})
</script>cold-lamp-11377
10/01/2021, 1:06 PMmysterious-toddler-20573
10/01/2021, 1:18 PMmysterious-toddler-20573
10/01/2021, 1:18 PMhtml
<script>
example()
</script>mysterious-toddler-20573
10/01/2021, 1:20 PMonLoad is going to be called every time any content is loaded upmysterious-toddler-20573
10/01/2021, 1:21 PMhtml
<script>
htmx.onLoad(async (elt) => {
if (elt.querySelector('#btn_request_logs') !== null) {
// Without this check, onLoad would execute this javascript for every htmx load. We only want this
// in case of a device details
let {Device} = await import("{% static 'device_admin/device_mgmt_commands.js' %}")
let {show_toast, getCookie} = await import("{% static 'device_admin/common.js' %}")
const device = new Device("{{ manageddevice.id }}", "{{ manageddevice.androidmanagementname }}")
elt.querySelector('#btn_request_logs').addEventListener('click', () => device.request_logs())
}
})
</script>mysterious-toddler-20573
10/01/2021, 1:21 PMcold-lamp-11377
10/01/2021, 1:26 PM