mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +00:00
removeProductBalcao trocado htmx por ajax
This commit is contained in:
@@ -46,8 +46,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{item.product.name}}</td>
|
<td>{{item.product.name}}</td>
|
||||||
<td>R$ {{item.product.price}}</td>
|
<td>R$ {{item.product.price}}</td>
|
||||||
<td><button
|
<td><button onclick="removeProductBalcao({{item.id}})"
|
||||||
hx-get="{% url 'removeProductBalcao' item.id %} " hx-trigger="click" hx-target="#list-products-balcao"
|
|
||||||
>🗑️ Excluir</button></td>
|
>🗑️ Excluir</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -8,7 +8,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{item.product.name}}</td>
|
<td>{{item.product.name}}</td>
|
||||||
<td>R$ {{item.product.price}}</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>
|
</tr>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -120,23 +120,32 @@ function addProductBalcao() {
|
|||||||
var qtd = document.getElementById('qtd-product').value;
|
var qtd = document.getElementById('qtd-product').value;
|
||||||
console.log(productId, comandaId)
|
console.log(productId, comandaId)
|
||||||
const url = `/balcao/addProductBalcaoTeclado${productId}/${comandaId}/${qtd}/`;
|
const url = `/balcao/addProductBalcaoTeclado${productId}/${comandaId}/${qtd}/`;
|
||||||
const listProductsBalcao = document.getElementById('list-products-balcao');
|
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},}).then(function(response) {
|
||||||
|
|
||||||
})
|
|
||||||
.then(function(response) {
|
|
||||||
return response.text();
|
return response.text();
|
||||||
}).then(function(text) {
|
}).then(function(text) {
|
||||||
var listProductsBalcaoElement = document.getElementById("list-products-balcao");
|
var listProductsBalcaoElement = document.getElementById("list-products-balcao");
|
||||||
listProductsBalcaoElement.innerHTML = text;
|
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;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user