简体   繁体   中英

Bootstrap modal close button doesnt work

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">&times;</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">

Have you tried (untested code):

jQuery(function($) {
    $('button.btn-primary').on('click', function() {
        $(this).parents('.modal').modal('hide');
    });
});

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(); }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM