If I comment the IF statement then the data-popup is working. But with IF statement the popup is not working. I did a lot of research and rewrote the form.
I think the code is good but why is the data-popup not showing if I add the following?:
if ($row['description'] == "Incorrect password o") {
$log .= "<td>";
$log .= "
<a class='btn btn-danger' data-popup-open='popup-" . $index . "' href='#' >Password reset</a>
<div class='popup' id='detail-" . $index . "' data-popup='popup-" . $index . "'>
<div class='popup-inner'>
<div class='row'>
<div class='well' >
<h3>Verzend nieuwe wachtwoord</h3>
<form role='form' action='login/requestnewpass/' method='POST' id='contactForm' data-toggle='validator' class='shake'>
<div class='row'>
<div class='form-group col-sm-6'>
<label for='requestnewpass' class='h4'>Username</label>
<input type='text' name='requestnewpass' value='" . $row['username'] . "' class='form-control' id='requestnewpass' placeholder='Enter name' required data-error='Vul hier je naam in'>
<div class='help-block with-errors'></div>
<input type='submit' name='submit' value='submit' class='btn btn-success'>
</div>
</div>
</form>
</div>
<p>
<a data-popup-close='popup-" . $index . "' href='#'>Close</a>
</p>
<a class='popup-close' data-popup-close='popup-" . $index . "' href='#'>x</a>
</div>
</div>
</div>";
$log .= "</td>";
} else {
$log .= "<td>";
$log .= "</td>";
}
<script>
$(function () {
//----- OPEN
$('[data-popup-open]').on('click', function (e) {
var targeted_popup_class = jQuery(this).attr('data-popup-open');
$('[data-popup="' + targeted_popup_class + '"]').fadeIn(350);
this.parent.firstchild()
e.preventDefault();
});
//----- CLOSE
$('[data-popup-close]').on('click', function (e) {
var targeted_popup_class = jQuery(this).attr('data-popup-close');
$('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
e.preventDefault();
});
});
</script>
html:
<div class="table-responsive" >
<table class="table table-striped persoontable table-hover" data-toggle="table"
data-show-columns="true"
data-show-toggle="true"
data-pagination="true"
data-show-refresh="true"
data-search="true">
<thead>
<tr>
<th data-sortable="true">Description</th>
<th data-sortable="true">Username</th>
<th data-sortable="true">Ip</th>
<th data-sortable="true">Website</th>
<th data-row-style="rowStyle" data-sortable="true">Level</th>
<th data-sortable="true">Created</th>
<th data-sortable="true">Reset password</th>
</tr>
</thead>
<tbody class="sortable">
<?php echo $log; ?>
</table>
</div>
</div>
With some extra debugging I found that the problem occurs only after I use the add on functions of bootstrap-table. The button clicks on the first page work, but once I use the pagination or sort functions the data click listeners will get overwritten.