MID*_*MID 38 modal-dialog twitter-bootstrap
我想在用户点击关闭btn时关闭模态.我认为我需要从modal.js覆盖这部分代码:
 hide: function (e) {
    e && e.preventDefault()
    var that = this
    e = $.Event('hide')//if I delete this line modal won't hide
    this.$element.trigger(e)
    if (!this.isShown || e.isDefaultPrevented()) return
    this.isShown = false
    $('body').removeClass('modal-open')
    escape.call(this)
    this.$element.removeClass('in')
    $.support.transition && this.$element.hasClass('fade') ?
      hideWithTransition.call(this) :
      hideModal.call(this)
我在正确的道路上吗?
Per*_*mal 67
启动模态时,您可以传递选项:
{
  keyboard: false,
  backdrop: 'static'
}
这将通过单击背景和转义按钮禁用关闭模式.或者可以将它们设置为data-属性.
Tab*_*res 65
您可以定义模态行为,定义数据键盘和数据背景.
 <div id="modal" class="modal hide fade in" data-keyboard="false" data-backdrop="static">
Vik*_*ram 10
试试这个吧
<div id="myModal" class="modal hide fade in" data-backdrop="static">
<div> </div>
</div>
在Jquery中制作它的最佳方法是:
<script type="text/javascript">
    $('#modal-id').modal({
        backdrop: 'static',
        keyboard: false
    });
</script>
或者在HTML中:
<div id="modal-id" class="modal hide fade in" data-keyboard="false" data-backdrop="static">
但是,如果您已经初始化了模态,则需要取消绑定模态的click事件,例如:
<script type="text/javascript">
    //this remove the close button on top if you need
    $('#modal-id').find('.close').remove();
    //this unbind the event click on the shadow zone
    $('#modal-id').unbind('click');
</script>
| 归档时间: | 
 | 
| 查看次数: | 62462 次 | 
| 最近记录: |