相关疑难解决方法(0)

在bootstrap模式上调用函数打开

我曾经使用过JQuery UI的对话框,它有一个open选项,你可以指定一些Javascript代码在打开对话框后执行.我会使用该选项使用我的函数选择对话框中的文本.

现在我想用bootstrap的模态做到这一点.以下是HTMl代码:

<div id="code" class="modal hide fade">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>Modal header</h3>
    </div>
    <div class="modal-body">
        <pre>
print 'Hello World'
Run Code Online (Sandbox Code Playgroud)

至于打开模态的按钮:

 <a href="#code" data-toggle="modal" class="btn code-dialog">Display code</a>
Run Code Online (Sandbox Code Playgroud)

我尝试使用按钮的onclick监听器,但是在模式出现之前显示了警告消息:

$( ".code-dialog" ).click(function(){
    alert("I want this to appear after the modal has opened!");
});
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-ui modal-dialog twitter-bootstrap

164
推荐指数
4
解决办法
32万
查看次数