How To Call Specific Model From Sprcific ID
Here i am working on adding user insurance details and also add their notifications alert system. Here is a snap for adding insurance: when user added their various insurance det
Solution 1:
Onclick of notification td just get the insurance id from table and update the modal like this . it will work generic.
$(document).ready(function(){
$(document).on('click','.notifier_click',function(){
var ins_id = $(this).closest('tr').find('td.insurance_main_id').text();
$('.insurance_modal_id').val(ins_id);
});
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table border="1px">
<thead>
<tr>
<th>insurance id</th>
<th>notification</th>
</tr>
</thead>
<tbody>
<tr>
<td class="insurance_main_id">1</td>
<td><a style="cursor: pointer;" data-toggle="modal" data-target=".notifier" class="notifier_click"><span class="fa fa-pencil"></span> Notfication</a></td>
<tr>
<tr>
<td class="insurance_main_id">2</td>
<td><a style="cursor: pointer;" data-toggle="modal" data-target=".notifier" class="notifier_click"><span class="fa fa-pencil"></span> Notfication</a></td>
<tr>
</tbody>
</table>
<div class="modal fade notifier" role="dialog">
<div class="modal-dialog col">
<!-- category delete Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Notification<script type="text/javascript"></script></h4>
</div>
<div class="modal-body">
<div class="container">
<div class="form-group">
<div class="table-responsive">
<table class="table table-bordered" id="dynamic_field">
<tr>
<td ><input type="text" name="insurance_id" class="insurance_modal_id"/> </td>
<td><select class="form-control" name="notify_type[]">
<option value="sms">SMS</option>
</select>
</td>
<td><input type="text" name="units[]" value="10" class="form-control name_list" /></td>
<td><select class="form-control" name="unit_type[]">
<option value="months">Months</option>
<option value="weeks">Weeks</option>
<option value="days">Days</option>
</select>
</td>
<td><button type="button" name="add" id="add" onclick="add_not_field();" class="btn btn-success">Add More</button></td>
</tr>
</table>
</div>
<!-- </form> -->
</div>
</div>
</div>
</div>
Post a Comment for "How To Call Specific Model From Sprcific ID"