Dynamic form with AJAX doesn't work
georgikolev7 opened this issue · 4 comments
Hello guys,
I have a problem with Calx.
I create my own dynamic form. For more easly using, I write the product line (contains input fields for name, qty, price, tax) in TPL file and call it with AJAX when user click on "plus" button and insert it after last product row.
The first product row without problem - perfectly calculate price, qty, tax.
Problem start when I add new product row with AJAX. When I just click in some of input fields in the new row, I receive couple errors from Calx.
I check the data-cell identifiter of the old row and the new row - they are different.
did you call $('#the_form_id').calx('update')
after adding the row?
Here is my code.
`$(function()
{
$(document).on('click', 'label.add-line', function(e) {
e.preventDefault();
var sheet = $form.calx('getSheet');
var id = $('div.line-item-box:last').data('box') + 1;
$.ajax(
{
type: 'GET',
data: 'action=getBox&line=' + id,
url: intelli.config.packages.app.url + 'subscriptions/',
success: function(response)
{
$(response).insertAfter('div.line-item-box:last');
}
});
sheet.refresh();
$form.calx('update');
});
});`
Did anybody know where I wrong?
Edit: I found the problem. The "span" element, that show total price, based on price * qty + VAT have data-formula attribute, but not have data-cell attribute. I fixed it and now it's works fine.