I' creating a table to add new lines where each line had an input quantity but doesn't work well.
When i add more than a line the quantiy of first input increment more than once.
I want that each input increment 1 time per click.
My html - jade:
table(class=["table","table-hover", 'table-reception'])
thead
tr
th Referência
th Designação
th Quantidade
tbody
My view: (When i read a bar code i add a new tr)
tr(class="item-article", id="#{data.ref}", data-codigo="#{data.codigo}")
td(class="td-ref")
span #{data.ref}
td(class="td-design")
span #{data.design}
td(class="td-qtt")
<input type='button' value='-' class='minus' />
<input type='text' size='10' class='value' value='0' />
<input type='button' value='+' class='plus' />
my jquery:
function btnPlusMinus()
{
$('.minus, .plus').click(function (e) {
e.preventDefault();
var $input = $(this).siblings('.value');
var val = parseInt($input.val(), 10);
$input.val(val + ($(this).hasClass('minus') ? -1 : 1));
$( ".barCode" ).val('');
$( ".barCode" ).focus();
});
}
Jquery - loading bar code:
function receptionArticle()
{
$('.barCode').change(function ()
{
barCode = $(this).val();
//alert($(this).val());
document.getElementById('scrollToReception').scrollIntoView();
$.get("/warehouse-reception-getArticle/"+encodeURIComponent(barCode), function(data)
{
if(data == 'false')
{
$.get("/warehouse-reception-popup/", function(data)
{
$(".popup").html('');
$(".popup").append(data);
$('.opacity').show();
$('.popup').show();
closeWarehousePopup();
});
}
else
{
$(".table-reception tbody").append(data);
$(".table-reception tbody tr:last").hide();
$('.table-reception tbody tr:last').css( "background-color", "#2ecc71" ).fadeIn(1000);
$( ".table-reception tbody tr:last" ).animate({
'background-color': "initial"
}, 5000);
$("#reception-message").hide();
$( ".barCode" ).val('');
$( ".barCode" ).focus();
btnPlusMinus();
}
});
});
}
Html:
If i add five row and increment the first input the result was 5 and not 1. If i in second row increment the result was 4 and 1. etc...
Thank you
<tr>with each of them containing the three<input>elements? Can you post the resulting html?