I have a function that adds some details to the DataTable, the function is activated by a button that is add, then it hides the modal. what i want is for the user to have the option to continue adding details a button that adds the details to the table, cleans the modal and doesn't hide it. Here I leave part of my code because it is very extensive.
function agregarDetalle() {
var detalleCaptura = $('#detalleCaptura');
var componentes = $('#componentes').val();
var tiempoColecta = $('#tiempoColecta').val();
rowNum++;
var t = detalleCaptura.DataTable();
t.row.add([
'<a href="#myModal" id="editRow" class="btn btn-primary btn-sm" title="Editar" custom-modal="true" data-toggle="modal" data-backdrop="static" data-keyboard="false" onClick="editRow(' + rowNum + ')"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>' +
'<a class="btn btn-danger btn-sm" id="idEliminarFila' + rowNum + '" title="Eliminar" onClick="deleteRow(' + rowNum + ')"><i class="fa fa-trash-o" aria-hidden="true"></i></a>',
'<input type="hidden" id="componentes' + rowNum + '" name="datosCaptura[add][row' + rowNum + '][componentes]" value="' + componentes + '" /> <p id="pcomponentes' + rowNum + '">' + componentes + '</p>',
'<input type="hidden" id="tiempoColecta' + rowNum + '" name="datosCaptura[add][row' + rowNum + '][tiempoColecta]" value="' + tiempoColecta + '" /><p id="ptiempoColecta' + rowNum + '">' + tiempoColecta + '</p>' +
]).draw(false);
$('#myModal').modal("hide");
return false;
}
<button type="button" id="agregarDetalle" data-dismiss="alert" class="btn btn-flat btn-success btn-save-coupon-ref" onClick="agregarDetalle()"><span class="fa fa-save"></span>Agregar</button>
<button type="button" class="btn btn-flat btn-success btn-save-coupon-ref" onClick="guardarYcrearNueva()"><span class="fa fa-save"></span>Crear y agregar otro</button>
I would like the second function to be executed until before the ("modal".hide)
You could pass parameters to the function depending on which button you hit, and then run the
hide
.Both buttons call
agregarDetalle()
and as a parameter you passtrue
orfalse
.