I'm trying to launch a remote bootstrap modal and populate a datatable inside the modal. The first time I launch the modal from link1
it works and sets the variables however if I click link2
the modal opens but uses the data from link1
and vise versa.
On the parent page I'm creating the link via php like this:
PHP:
echo '<a data-toggle="modal" data-target="#viewComments" href="./remotemodal.php?object='.urlencode($row['OBJECT_NAME']).'&date='.urlencode($row['DATE_OCCURED']).'&error='.urlencode($row['ERROR']).'" class="btn-sm btn-info" ><i class="fa fa-comment-o"></i> View Comments</a>';
It populates the links correctly, similar to below:
Link1: remotemodal.php?object=Cluster1&date=03%2F01%2F2016+23%3A48&error=Error1
Link2: remotemodal.php?object=Cluster2&date=03%2F02%2F2016+17%3A44&error=Error2
Here is the PHP of the remotemodal.php:
PHP:
<?php
$object = NULL;
$date = NULL;
$error = NULL;
echo '<script type="text/javascript">alert("' . $object . '")</script>';
echo '<script type="text/javascript">alert("' . $date . '")</script>';
echo '<script type="text/javascript">alert("' . $error . '")</script>';
if ( !empty($_GET['object'])) {
$object = $_GET['object'];
$date = $_GET['date'];
$error = $_GET['error'];
}
echo '<script type="text/javascript">alert("' . $object . '")</script>';
echo '<script type="text/javascript">alert("' . $date . '")</script>';
echo '<script type="text/javascript">alert("' . $error . '")</script>';
?>
If I goto the links directly they work and I see the correct variables in the js alert. I've tried to clear the modal data from the parent page on modal close but nothing is working
Javascript:
<script>
$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});
</script>