为Bootstrap Modal(模态框)全局添加拖拽操作

2年前 (2022) 程序员胖胖胖虎阿
139 0 0

 在js中绑定方法

$(document).on("show.bs.modal", ".modal", function(){
    $(this).draggable({
//        handle: ".modal-header"   // 只能点击头部拖动
    });
    $(this).css("overflow", "hidden"); // 防止出现滚动条,出现的话,你会把滚动条一起拖着走的
});

  

事件 描述 示例
show.bs.modal 在调用 show 方法后触发。 $("#identifier").on('show.bs.modal', function(){//do sth. });
show.bs.modal 当模态框对用户可见时触发(将等待 CSS 过渡效果完成)。 $("#identifier").on('shown.bs.modal', function(){//do sth. });
hide.bs.modal 当调用 hide 方法时触发。 $("#identifier").on('hide.bs.modal', function(){//do sth. });
hidden.bs.modal 当模态框完全对用户隐藏时触发。 $("#identifier").on('hidden.bs.modal', function(){//do sth. });

版权声明:程序员胖胖胖虎阿 发表于 2022年9月5日 下午12:56。
转载请注明:为Bootstrap Modal(模态框)全局添加拖拽操作 | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...