i'm looking to open a modal using bootstrap 4. If I check the documentation, this is working fine.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
But in fact I would like to call the modal from a different page. It means myModal should not be on the same page than the button. But all I tried failed. Do you have any idea ? Thanks
Moreover I would like to use a link with <a href=....></a>
instead of button.
To be more specific; here ic what I really have, (was working with bootstrap 2 and I try to make it work with bootstrap 4) but it's not working or at least not as expected.
Page 1
<a class="btn btn-mini btn-info avia-modal" href="PAGE_MODAL_URL"></a>
js side
$(".avia-modal").click( function() {
ouvrirModal(this);
$("#idurl").val($(this).attr('rel'));
} );
/**
* Fonctions popup modal
*/
function ouvrirModal(elt){
href = $(elt).prop("href");
$('#aviaModal').modal();
$('#aviaModal iframe.modal-body').prop("src", href);
$('#aviaModal iframe.modal-body').removeClass("d-none");
$('#aviaModal div.modal-body').addClass("d-none");
}
/**
* itialisation modal
*/
function initModal(btnSave){
if(btnSave){
$("#aviaModal .avia-btn-save").removeClass("d-none");
$("#aviaModal .avia-btn-save").click( function() {
window.frames["iframemodal"].window.saveAction();
});
}
}
/**
* Réinitialisation modal
*/
function resetModal(){
$("#aviaModal .avia-btn-save").addClass("d-none");
$('#aviaModal').modal('d-none');
}
$(document).ready(function(){
parent.$("#aviaModal .modal-header h3").html("Historique");
parent.$("#aviaModal").addClass("modal-historique");
});