steep-gold-4096
04/12/2023, 2:50 AMhtml
# index.html
<button hx-post="/clicked" hx-swap="afterend">
Click Me
</button>
# clicked.html
{% block content %}
{% for call in service_calls %}
<h3>{{ call.date }} from {{ call.callers_name }}</h3>
<p>{{ call.note }}</p>
<mark>
{% if call.rma is not None %}
RMA# {{ call.rma }}
{% else %}
RMA not issued.
{% endif %}
</mark>
{% endfor %}
{% endblock content %}
py
# urls.py
path('clicked', test_view, name='clicked'),
# views.py
csrf_exempt
def test_view(request):
if request.method == "POST":
greeting = "Hello Post Method!"
service_calls = ServiceCall.objects.all()
context = {
'greeting': greeting,
'service_calls': service_calls,
}
return render(request, 'clicked.html', context)
steep-gold-4096
04/12/2023, 3:01 AMmammoth-airplane-32618
04/12/2023, 3:10 AMkind-kite-734
04/12/2023, 3:18 AMsteep-gold-4096
04/12/2023, 3:24 AMlocalhost:8000/records?query=1
I'm not sure how to create a view or even link that keeps that but adds onto it like localhost:8000/records?query=1&sort=date
mammoth-airplane-32618
04/12/2023, 1:16 PMsteep-gold-4096
04/12/2023, 9:16 PMhtml
<!-- equipment_service.html -->
<h2>Search for Service Calls</h2>
<form action="{% url 'search_enclosure_service' %}" method="get">
<input type="text" class="form-control" name="query" placeholder="Exact enclosure serial number">
<button type="submit" class="btn btn-primary mt-4" value="Find By Enc">Find Enclosure</button>
</form>
<!--
at this point it has a get request on the url which is equipment serial number
localhost:8000/servicecalls/?query=123456
-->
{% for call in service_calls %}
{% if call.return_manufacturer_authorization %}<button hx-get='/clicked' hx-target='#firsthtmx'>{{ call.return_manufacturer_authorization }}</button>{% endif %}
<div id='firsthtmx'>
</div>
I have a basic view that sends "Hello World" to the firsthtmx and its working. But now I'm trying to figure out how to send the RMA through the button to the view.steep-gold-4096
04/16/2023, 10:28 PMdry-belgium-23584
04/20/2023, 1:21 PMdry-belgium-23584
04/20/2023, 1:22 PMhtmx.onLoad(function (content) {
[].slice.call(content.querySelectorAll('#datatable')).map(function (element) {
new simpleDatatables.DataTable(element, {
sortable: true
});
htmx.process(element);
});
});
<button class="btn btn-sm btn-warning" hx-get="{% url 'edit-product' pk=product.id %}" hx-target="#dialog">Edit</button>
bitter-machine-55943
04/22/2023, 3:04 AMbitter-machine-55943
04/22/2023, 3:04 AMbland-coat-6833
04/22/2023, 11:46 AMbland-coat-6833
04/22/2023, 11:47 AMmagnificent-barista-99118
04/25/2023, 6:38 PMmagnificent-barista-99118
04/25/2023, 6:38 PMfreezing-hydrogen-72693
04/25/2023, 8:03 PMbitter-monkey-50309
04/25/2023, 10:40 PMhtmx.onLoad()
event that'll probably let you reinitialize the JS when the partial is loaded in.future-table-82610
04/25/2023, 10:58 PMhx-boost
enabled, whenever I load a new page, this div
is sent from the server as part of the template, but ultimately htmx
removes it from the template (and yes it's an empty div), any idea why?
<div class="toast-container position-fixed bottom-0 end-0 p-3 mt-7" id="toast-messages" hx-swap-oob="beforeend:#toast-messages">
</div>
future-table-82610
04/25/2023, 11:00 PMbillions-window-36824
04/26/2023, 10:30 PMrefined-waiter-90422
04/26/2023, 11:20 PMrefined-waiter-90422
04/26/2023, 11:21 PMmagnificent-barista-99118
04/26/2023, 11:44 PMblue-gold-89534
04/27/2023, 2:51 PM{% block js %}
within a ``and the library static files are defined in the base.html
.
When I just paste the example from charts.js page:
<script>
const ctx = document.getElementById('myChart');
new Chart(ctx, {
type: 'line',
data : { labels : [ 1500, 1600, 1700, 1750, 1800, 1850, 1900, 1950, 1999, 2050 ],
datasets : [ { data : [ 186, 205, 1321, 1516, 2107, 2191, 3133, 3221, 4783, 5478 ],
label : "America",
borderColor : "#3cba9f",
fill : false}]
},
options : { title : {display : true, text : 'Chart JS Line Chart Example' } }
});
</script>
I get a lot of caught SyntaxError: Identifier 'ctx' has already been declared
. the <div>
around the chart html has hx-preserve = True
set. Nevertheless I get the error whenever something loads on other parts of the page.blue-gold-89534
04/27/2023, 2:51 PMprehistoric-cat-63987
05/05/2023, 10:37 AMancient-shoe-86801
05/05/2023, 4:14 PMrefined-waiter-90422
05/05/2023, 4:25 PMgreat-cartoon-12331
05/05/2023, 4:26 PM