I have the following javascript code
$("#modal-yes-button").click(function (){
$("#myModal").modal('hide');
$(".modal-body").load('/url/that/returns/an/html/');
$("#myModal").modal('show');
});
and the following modal
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<h3>This is a question answer yes or later</h3>
</div>
<div class="modal-footer">
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Maybe Later</button>
<button id="modal-yes-button" class="btn btn-info" aria-hidden="true">Yes</button>
</div>
</div><!--modal-content-->
</div><!--modal-dialog-->
</div><!--myModal-->
I want the usere to press the yes button hide the modal(it says that bootstrap won't allow modal open when another one is open) load the new html content for the .modal-body and dipslay the modal dialog again. Only what i get is black screen(like when it shadows for the modal to appear) but the modal never appears. I played with it using the chrome dev tools and the modal appears normally
chrome dev-tools
modaldialog = $("#myModal");
modaldlgBody = $(".modal-body");
modaldlgBody.load('/url/that/returns/html/');
modaldialog.modal('show');
With the above commands the new new "body" is loaded normally. But if i try to load the dialog first and then press the yes button even when triggering the modal from the chrome dev-tools i get the same behavour, black screen. What could be wrong?
chrome dev-tools that giving the same black screen
modaldialog = $("#myModal");
modaldialog.modal('show');
#pressing yes gets me the same black screen.
This is how it worked. I had to run the code
instead of
I am not quite sure why this is like this. I thought using $ is a jquery object so
should have worked. But it didn't. If you have any ideas why please comment I like to know the why in things :)