the button, use to click that pass direct to open in the modal
<button type="button" class="btn btn-primary waves-effect waves-light debit-btn" data-toggle="modal" data-animation="bounce" data-target=".bs-example-modal-center-dr" data-account_id="" >Debit</button>
modal section, after button clicked the modal suppose to open and show the data
<div class="modal fade bs-example-modal-center-dr" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title mt-0" id="myLargeModalLabel">Add Debit</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
Jquery and ajax, i use on click event to get the id and pass then to the ajax in order to return data from a controller
$(document).ready(function() {
$('.debit-btn').on('click', function (){
var account_id = $(this).data('account_id');
//alert(account);
$.ajax({
url : "<?php echo base_url('Debtors_creditors_more_details/get_credit_trans');?>",
method : "POST",
data : {account_id: account_id},
async : true,
dataType : 'json',
success: function(data){
//calculateQuantity(qty, data);
$('#model-debit').modal('show');
console.log(data);
alert('hello');
}
});
return false;
});
});
Note:-
This cant open a modal after adding on click function, please help
2
Answers
In your click function add
This would force the modal to open using js.
Your View:-
Bootstrap Modal Code:-
JQUERY AJAX Code:-
Controller Code:-
Modal Code:-
Create in View accountinModal.php :-