How to pass values arguments to modal.show() function in Bootstrap
You could do it like this:
<a class="btn btn-primary announce" data-toggle="modal" data-id="107" >Announce</a>
Then use jQuery to bind the click and send the Announce data-id as the value in the modals #cafeId:
$(document).ready(function(){
$(".announce").click(function(){ // Click to only happen on announce links
$("#cafeId").val($(this).data('id'));
$('#createFormId').modal('show');
});
});
Use
$(document).ready(function() {
$('#createFormId').on('show.bs.modal', function(event) {
$("#cafeId").val($(event.relatedTarget).data('id'));
});
});
Here's how i am calling my modal
<a data-toggle="modal" data-id="190" data-target="#modal-popup">Open</a>
Here's how i am obtaining value in the modal
$('#modal-popup').on('show.bs.modal', function(e) {
console.log($(e.relatedTarget).data('id')); // 190 will be printed
});