How to refresh a modal without leaving/closing the modal
How to refresh a modal without leaving/closing the modal
In the attached image of the modal, clicking the Save button will add an additional row in the DataTable but does NOT close the modal. How can I refresh the modal title dynamically with information from the most recently added row in the DataTable (sorted by Status Date/Time). So, in the example below, once Save was clicked the Status of IN SAFE should show in the modal title.
I also want to reset the DropDown when Save is clicked. I can reset the two input boxes.
Here is the code piece I have thus far for the save functionality.
function save()
{
$('#btnSave').text('saving...'); //change button text
$('#btnSave').attr('disabled', true); //set button disable
// var username = $("#USERNAME").val();
var pnum = $("#PASSPORT_NUMBER").val();
// ajax adding data to database
$.ajax({
url: "<?php echo site_url('/index.php/status/ajax_add') ?>/" + username + "/" + pnum,
type: "POST",
data: $('#form').serialize(),
dataType: "JSON",
success: function (data)
{
if (data.status) //if success reload ajax table
{
// $('#modal_form').modal('hide');
reload_info_table();
$("#UPS_TRACKING_NUMBER").val("");
$("#COMMENTS").val("");
//$("#PASSPORT_STATUS").index(-1); // val("- Select -");
//alert('Add Status ' + name_and_status);
//$('.modal-title').text('Add Status ' + name_and_status); //
reload_table();
}
$('#btnSave').text('Save'); //change button text
$('#btnSave').attr('disabled', false); //set button enable
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Error adding / updating data');
$('#btnSave').text('Save'); //change button text
$('#btnSave').attr('disabled', false); //set button enable
}
});
}