My background is in Java and object orientated programming and I'm just starting out in bootstrap. I want to load a modal into another page using javascript and then show it on a button click but I'm not sure of the process. Is this even the correct way to go about this or is html/javascript more procedural?
I want to load the modal in createOrder.html into navbar.html and I have the following. Obviously this doesn't work as I only get a darkened screen when I click the button so what is the correct way to do this?
navbar.html
...
<script>
$(function() {
$("#createOrder").load("createOrder.html");
});
</script>
<button type="button" id="createOrderButton" class="btn btn-default navbar-btn" data-toggle="modal" data-target="#createOrder">Create</button>
...
createOrder.html
<!-- Modal -->
<div class="modal fade" id="createOrder" tabindex="-1" role="dialog" aria-labelledby="createOrderLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Create Order</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Create</button>
</div>
</div>
</div>
</div>
As a side note I understand bootstrap allows you to do $('#myModal').modal(show) but how would I call that modal if the code for it resides on a different page? and if I want to stick to an MVC architecture wouldn't it make more sense to call it via data attributes?