Reputation: 11
I have a problem with close button at my modal popup. Even if i click on x - modal is still open. But it occures while the modal is in auto open mode.
Here it works:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<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">header</h4>
</div>
<div class="modal-body">
body
</div>
<div class="modal-footer">
Regulamin karty dostępny w salonie.
<!-- <a href="#contactSlice"> <button type="button" class="btn btn-primary" data-dismiss="modal" aria-label="Close">footer</button></a> -->
</div>
</div>
</div>
</div>
Here it doesnt work:
<div class="modal fade in" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
Upvotes: 0
Views: 2441
Reputation: 2599
Try something like this. It eliminates the original close button and implements one through the javascript. You can add it to your modal options.
$("#dialog-1").dialog({
autoOpen: false,
modal: true,
width: 500,
height: 300,
buttons: { 'close': function () { $(this).dialog('close'); } },
open: function (event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
Upvotes: 0
Reputation: 5849
Have you tried (untested code):
jQuery(function($) {
$('button.btn-primary').on('click', function() {
$(this).parents('.modal').modal('hide');
});
});
Upvotes: 1