简体   繁体   中英

Disable Twitter Bootstrap modal

I've taken a look at Bootstrap's JS guidelines, and this code disables the Twitter's Bootstrap modal:

$('#myModal').on('show', function (e) {
if (!data) return e.preventDefault() // stops modal from being shown
})

However, upon clicking the modal, it doesn't open the object (an image, in this case, using Bootstrap Image Gallery: https://github.com/blueimp/Bootstrap-Image-Gallery ). It just disables the click function altogether.

I've also tried this snippet to disable the modal gallery:

$(document.body).off('.modal-gallery.data-api')

But it doesn't seem to disable it.

How would I write the jQuery so that the modal gallery is disabled and images open regularly as a link? (Am needing this snippet for a mobile site that will be implemented in the footer, after all scripts have been executed.)

You can disable the automatic modal binding by removing data-toggle="modal" and bind your click event

$('#mybutton').click(function (e) {
  if (data) {
    e.preventDefault();
    $('#myModal').modal();
  }
});

这将打开没有引导模式的图像。

div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-use-bootstrap-modal="false" 

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