mysterious-toddler-20573
08/24/2020, 7:46 PMmysterious-toddler-20573
08/24/2020, 7:46 PMbar
on the event detail with the value blah
most-jelly-15242
08/24/2020, 7:50 PMmysterious-toddler-20573
08/24/2020, 7:50 PMmysterious-toddler-20573
08/24/2020, 7:50 PMmysterious-toddler-20573
08/24/2020, 7:51 PMmost-jelly-15242
08/24/2020, 8:32 PMmysterious-toddler-20573
08/24/2020, 11:05 PMgreat-vase-24934
08/25/2020, 4:11 AMhx-get
<a hx-get="{% url 'create-comment' item.id %}" hx-target="#reply">reply</a>
<article id="reply"></article>
<script src="https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.7/quill.min.js" integrity="sha512-P2W2rr8ikUPfa31PLBo5bcBQrsa+TNj8jiKadtaIrHQGMo6hQM6RdPjQYxlNguwHz8AwSQ28VkBK6kHBLgd/8g==" crossorigin="anonymous"></script>
<script>
let quill = new Quill('//*[@id="editor"]', {
theme: 'snow'
});
</script>
and i'm inserting a form when a user clicks reply
just in case ya'll wondering what the form looks like - django form
class ItemForm(forms.Form):
body = forms.CharField(label="Pintext", widget=forms.Textarea)
image = forms.FileField(
widget=forms.ClearableFileInput(
attrs={"multiple": True, "data-max-files": 5, "data-max-file-size": "5MB"},
),
label="Image Attachments",
required=False,
)
tags = forms.CharField(max_length=200, required=False)
body.widget.attrs.update({"id": "editor", "class": "editable"})
great-vase-24934
08/25/2020, 4:13 AMtall-dinner-62086
08/25/2020, 8:18 AMtall-dinner-62086
08/25/2020, 8:20 AMtall-dinner-62086
08/25/2020, 8:21 AMhtmx:afterOnLoad
event, and initialize quill there.tall-dinner-62086
08/25/2020, 11:04 AMtall-dinner-62086
08/25/2020, 11:39 AMmysterious-toddler-20573
08/25/2020, 2:25 PMjs
htmx.onLoad(function(content){
let quill = new Quill('//*[@id="editor"]', {
theme: 'snow'
});
});
It would be better to find stuff in the content
rather than doing a global search, in case Quill isn't reentrantmysterious-toddler-20573
08/25/2020, 2:27 PMhx-swap="attribute:value"
option in htmx, but if you replace an input (and it has a stable ID) we try to keep the caret position consistent so I figured it wasn't worth itgreat-vase-24934
08/25/2020, 2:48 PMgreat-vase-24934
08/25/2020, 6:43 PMclass CommentForm(forms.Form):
body = MarkdownxFormField()
& is there a way htmx can render these widgets when I do htmx-get
great-vase-24934
08/25/2020, 6:43 PMgreat-vase-24934
08/25/2020, 7:31 PMmysterious-toddler-20573
08/25/2020, 7:48 PMhtmx.onLoad
and use the content passed in to initialize the widgets. Turbolinks is much more mature than htmx and is designed to "just work" with html that is not designed for AJAX. I'm hoping to eventually match it for "just working" but as of right now I think you might have more success with using that, and maybe htmx for some smaller parts of your project.mysterious-toddler-20573
08/25/2020, 7:48 PMgreat-vase-24934
08/25/2020, 8:02 PMhx-boost="true"
is there a way to opt on some elements ?mysterious-toddler-20573
08/25/2020, 8:03 PMfalse
to cancel it for a given areatall-dinner-62086
08/26/2020, 8:12 AMhx-swap="attribute:value"
option in htmx, but if you replace an input (and it has a stable ID) we try to keep the caret position consistent so I figured it wasn't worth it
@mysterious-toddler-20573 Budgeting app, user can input cost of materials or load the cost from the database. I could just return the whole element, but seemed wasteful. Also gonna need to have a "load costs for all materials" button and that would be too expensive when these budgets get a bit larger on the hundreds of materials scale.tall-dinner-62086
08/26/2020, 8:14 AMhtmx.defineExtension('swap-value', {
onEvent : function(name, evt) {
if (name == 'htmx:beforeOnLoad') {
evt.detail.target.value = evt.detail.xhr.response;
return false;
}
return true;
},
});
great-vase-24934
08/26/2020, 8:57 PMgreat-vase-24934
08/26/2020, 8:58 PMmysterious-toddler-20573
08/26/2020, 9:02 PM