jquery - resume submit after event.preventDefault -
i'm trying achieve simple data-flow there must i'm not getting.
- i have table n rows.
- each row has own form submit button , hidden input.
- i want user click on button , prompt displayed.
- in prompt can insert date.
- after inserted date, hidden input value selected date , form submitted.
this code i'm using without success:
<td> <form id="form_{{ document.id }}" class="form-fattura-saldata" action="my-file.php" method="post"> <input type="hidden" class="data-pagamento" name="data-pagamento" value=""> <button class="btn btn-default fattura_saldata" type="submit">saldata</button> </form> </td>
and jquery code:
var saldatafatturachange = function(event) { event.preventdefault(); var prompt = bootbox.prompt("confermare la data di pagamento", function(result) { if (result === null) { } else { $('.data-pagamento').val(result); } }); $('.bootbox-input').daterangepicker({ startdate: new date(), format: 'dd/mm/yyyy', singledatepicker: true }); }; $('.form-fattura-saldata').each(function() { $(this).on('submit', saldatafatturachange); });
the main problem can prevent submit action don't know how re-sumbit form. , don't know how assign value of hidden input of form after user has choose date.
any appreciated.
p.s. i'm using bootstrap, not relevant @ all.
that's how resolved question:
var saldatafatturachange = function(event) { event.preventdefault(); var currenttarget = event.target; var prompt = bootbox.prompt("confermare la data di pagamento", function(result) { if (result === null) { } else { $(currenttarget).find('.data-pagamento').val(result); currenttarget.submit(); } }); $('.bootbox-input').daterangepicker({ startdate: new date(), format: 'dd/mm/yyyy', singledatepicker: true }); }; $('.form-fattura-saldata').each(function() { $(this).on('submit', saldatafatturachange); });
simply, event has event.target target of event fired. simple achieve.
Comments
Post a Comment