removeProductBalcao trocado htmx por ajax

This commit is contained in:
2024-12-27 17:17:17 -03:00
parent 1beb2e00b2
commit 356d45c3e5
4 changed files with 21 additions and 10 deletions

View File

@@ -46,8 +46,8 @@
<tr>
<td>{{item.product.name}}</td>
<td>R$ {{item.product.price}}</td>
<td><button
hx-get="{% url 'removeProductBalcao' item.id %} " hx-trigger="click" hx-target="#list-products-balcao"
<td><button onclick="removeProductBalcao({{item.id}})"
>🗑️ Excluir</button></td>
</tr>

Binary file not shown.

View File

@@ -8,7 +8,9 @@
<tr>
<td>{{item.product.name}}</td>
<td>R$ {{item.product.price}}</td>
<td><button hx-get="{% url 'removeProductBalcao' item.id %} " hx-trigger="click" hx-target="#list-products-balcao" >🗑️ Excluir</button></td>
<td><button onclick="removeProductBalcao({{item.id}})"
>🗑️ Excluir</button></td>
</tr>
{% endfor %}

View File

@@ -120,23 +120,32 @@ function addProductBalcao() {
var qtd = document.getElementById('qtd-product').value;
console.log(productId, comandaId)
const url = `/balcao/addProductBalcaoTeclado${productId}/${comandaId}/${qtd}/`;
const listProductsBalcao = document.getElementById('list-products-balcao');
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
})
.then(function(response) {
},}).then(function(response) {
return response.text();
}).then(function(text) {
}).then(function(text) {
var listProductsBalcaoElement = document.getElementById("list-products-balcao");
listProductsBalcaoElement.innerHTML = text;
})
}
// reloadPage()
function removeProductBalcao(id) {
const url = `/balcao/removeProductBalcao${id}/`;
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},}).then(function(response) {
return response.text();
}).then(function(text) {
var listProductsBalcaoElement = document.getElementById("list-products-balcao");
listProductsBalcaoElement.innerHTML = text;
})
}