mammoth-family-48524
05/02/2023, 6:23 AMbland-coat-6833
05/02/2023, 9:10 AMstocky-dentist-80693
05/02/2023, 9:12 AMhigh-pencil-36972
05/02/2023, 9:17 AMhigh-pencil-36972
05/02/2023, 10:00 AMsome-vegetable-82547
05/02/2023, 10:39 AMeval
, no new imports) and deployment of new client side code is super painful, so HTMX was really heaven sent for ussome-vegetable-82547
05/02/2023, 10:42 AMhx-swap="morphdom"
and either it doesn't work or not as great as I thought. I have two simple lists that get updated ever ~5s and every time that happens, I'm losing my scroll position.
I have hx-ext="morphdom-swap"
on my body, the hx-swap
on a root element and have the required packages installed.
Any hints what I might be doing wrong?
PS: I also tried Idiomorph, but https://github.com/bigskysoftware/idiomorph/issues/8mammoth-family-48524
05/02/2023, 11:45 AMbitter-machine-55943
05/02/2023, 12:20 PMmysterious-toddler-20573
05/02/2023, 1:30 PMhttps://cdn.discordapp.com/attachments/725789747212976259/1102950239356342333/FvH_r1xaUAAo5Pp.png▾
proud-librarian-99598
05/02/2023, 3:57 PMhigh-pencil-36972
05/02/2023, 7:47 PMhigh-pencil-36972
05/02/2023, 8:01 PMjava
@GetMapping(value="/create", headers = "HX-Request")
public HtmxResponse getUserCreatePartial(Model model){
getRolesAndPermissions(model);
model.addAttribute("form", new UserRequest());
return new HtmxResponse().addTemplate(String.format("%s/index :: user-create-form", path));
}
@PostMapping(value="/create", headers = "HX-Request")
public HtmxResponse postUserCreate(@ModelAttribute("form") @Valid UserRequest userRequest, Model model, BindingResult bindingResult){
if(bindingResult.hasErrors()){
model.addAttribute("form", new UserRequest());
return new HtmxResponse().addTemplate(String.format("%s/index :: user-create-form", path));
}
return new HtmxResponse().addTemplate(String.format("%s/index :: user-list", path));
}
html
<form class="ui form" id="user-create-form" th:object="${form}" novalidate="novalidate">
<div id="replace-form">
...
<input type="hidden" data-th-name="${_csrf.parameterName}" th:value="${_csrf.token}" />
</div>
<button class="ui primary button" hx-post="/hx/users/create">CREATE</button>
</form>
proud-librarian-99598
05/02/2023, 9:07 PMproud-librarian-99598
05/02/2023, 9:14 PMhigh-pencil-36972
05/02/2023, 9:34 PMhigh-pencil-36972
05/02/2023, 9:40 PMbitter-machine-55943
05/02/2023, 11:00 PMgorgeous-ghost-95789
05/02/2023, 11:04 PMenough-petabyte-50314
05/03/2023, 1:04 AMearly-afternoon-72189
05/03/2023, 1:21 AMearly-afternoon-72189
05/03/2023, 1:27 AMfunction markerOnClick(e) {
// console.dir(e)
// console.log(e.target.options)
var planterId = e.target.options.planterId
// raise an htmx request to load_planter/planterId
htmx.ajax('GET', '/load_planter/' + planterId, { target: '#dialog' })
}
This is the button I have to EDIT:
<div class="card-footer">
<div class="modal-footer">
<div class="col text-center pt-3">
<a href="{% url 'intakeHome' %}" class="btn btn-primary w-100" target="_blank">New Planter</a>
</div>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" href="{% url 'plantersdetail' data.id %}" id="editPlanterBtn">Edit Planter</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
</div>
</div>
refined-pillow-25368
05/03/2023, 7:23 PMmysterious-toddler-20573
05/03/2023, 8:04 PMgorgeous-airport-54386
05/03/2023, 8:36 PM<portal>
count? idk if it's a thing anymore butearly-afternoon-72189
05/03/2023, 8:36 PMmysterious-toddler-20573
05/03/2023, 8:41 PMhttps://cdn.discordapp.com/attachments/725789747212976259/1103421036415942778/FZfTGULXgAIWbJV.png▾
blue-gold-89534
05/04/2023, 8:39 AM<p hx-target="this"
hx-indicator="#spinner"
hx-swap="outerHTML"
hx-get="{% url 'command' "start" %}">
<img src="{% static 'images/foo.svg' %}">click
<img id="spinner" class="htmx-indicator" src="{% static 'images/loading.gif' %}"/>
</p>
I want to replace the foo.svg with the loading.gif on click, or the whole innerHTML of <p>
if possible. Is hx-indicator
the correct tool for the job? My other idea was to return the gif with an hx-redirect, but that seems overpowered?bland-coat-6833
05/04/2023, 8:40 AMhttps://cdn.discordapp.com/attachments/725789747212976259/1103602065500012635/image0.jpg▾