【发布时间】:2019-11-14 20:39:18
【问题描述】:
在我使用 PHP ajax 和 MySQLi 成功编辑数据后, “
<input type="text" class="tagsinput"/>”未正确初始化。 我尝试了这段代码,它可以工作,但不是正确的形式
$(document).ajaxComplete(function () {
$(document).find('.tagsinput').tagsInput();
});
这是尚未提交的表单的图片
这是成功编辑数据的图片,但我要编辑 再次
这是我的ajax调用代码
$(document).on('click', '.edit_fp_follow_up', function () {
$fp_follow_up_id = $(this).val();
$method = $('#method' + $fp_follow_up_id).val();
if (confirm('Are you sure you want to edit this follow-up?')) {
$.ajax({
type: "POST",
url: "action/editfpfollowup.php",
cache: false,
async: false,
data: {
fp_follow_up_id: $fp_follow_up_id,
method: $method,
edit: 1,
},
success: function () {
$('#alert').slideDown();
$('#alerttext').text('Successfully updated Follow-up Schedule!');
setTimeout(function () {
$('#alert').fadeOut('slow');
}, 1500);
$(document).ajaxComplete(function () {
$(document).find('.tagsinput').tagsInput();
});
show_follow_up_familyplanning();
}
});
}
});
这是我的模态代码
<div class="modal fade" id="edit_fp_follow_up<?php echo $fetch1['fp_follow_up_id']; ?>" tabindex="-1" role="dialog" aria-labelledby="defModalHead" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<center>
<div id="modallabel2" class="alert alert-danger" style="display:none;">
<center><span id="checkfield2"></span></center>
</div>
</center>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="defModalHead"><strong>Update Follow-up Visit - Family Planning</strong></h4>
</div>
<div class="modal-body">
<form id="fpfollowup">
<fieldset>
<div class="col-md-12">
<div class="form-group">
<label>Method/Brand</label>
<input type="text" class="tagsinput" id="method<?php echo $fetch1['fp_follow_up_id']; ?>" value="<?php echo $fetch1['method_brand']; ?>" data-role="tagsinput" required />
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button type="button" value="<?php echo $fetch1['fp_follow_up_id']; ?>" class="btn btn-success edit_fp_follow_up">Save</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
这是我表中的代码
<div class="table-responsive">
<table id="fpfollowuptable" class="table datatable hover">
<thead>
<tr class="warning">
<th>
<center>Patient ID</center>
</th>
<th>
<center>Patient Name</center>
</th>
<th>
<center>Remarks</center>
</th>
<th>
<center>Next Service Date</center>
</th>
<th>
<center>Status</center>
</th>
<th>
<center>Actions</center>
</th>
</tr>
</thead>
<tbody>
<?php
require '../require/config.php';
$query1 = $conn->query("SELECT * FROM `fp_follow_up` NATURAL JOIN `patient` WHERE `fp_follow_up`.`patient_id` = `patient`.`patient_id` ORDER BY `fp_follow_up_id` DESC") or die(mysqli_error());
while($fetch1 = $query1->fetch_array()){
?>
<tr>
<td>
<center><strong><?php echo $fetch1['year']?><?php echo "0".$fetch1['patient_id']?></strong></center>
</td>
<td>
<center><strong><?php echo $fetch1['patient_name']?></strong></center>
</td>
<td>
<center><?php echo $fetch1['remarks']?></center>
</td>
<td>
<center><?php echo $fetch1['next_service_date']?></center>
</td>
<td>
<center>
<?php
if ($fetch1['follow_up_status'] == 'Pending')echo "<span class='badge badge-danger animated infinite pulse' style='animation-duration:.8s;'>Pending</span>";
if ($fetch1['follow_up_status'] == 'Done')echo "<span class='badge badge-info'>Done</span>";
if ($fetch1['follow_up_status'] == 'Cancelled')echo "<span class='badge badge-warning'>Cancelled</span>";
?></center>
</td>
<td>
<center><button class="btn btn-sm btn-info" data-toggle="modal" data-target="#edit_fp_follow_up<?php echo $fetch1['fp_follow_up_id']; ?>">UPDATE</button></center>
</td>
<?php require('../modals/edit_fp_follow_up.php'); ?>
</tr>
<?php
}
$conn->close();
?>
</tbody>
</table>
</div>
【问题讨论】:
标签: php jquery html ajax bootstrap-tags-input