在js中绑定方法
$(document).on("show.bs.modal", ".modal", function(){
$(this).draggable({
// handle: ".modal-header" // 只能点击头部拖动
});
$(this).css("overflow", "hidden"); // 防止出现滚动条,出现的话,你会把滚动条一起拖着走的
});
bootstrap modal 的events:
查了好久才查到:(
| 事件 | 描述 | 示例 |
|---|---|---|
| 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. }); |
详细参考:http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html

本文介绍如何使用jQuery在JavaScript中为Bootstrap模态框绑定拖拽等自定义行为,并列举了模态框的各种事件及其用途。

被折叠的 条评论
为什么被折叠?



