2

I'm using the modal plugin from twitter-bootstrap and i'd like to know the time that the modal spends in appear to show an alert before.

In this example that I did you can see what I mean: http://tinker.io/e69ff/6

HTML

<button id="mod" class="btn btn-primary btn-block" data-toggle="modal" data-target="#myModal">
    hello
</button>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
      Hello all!
  </div>
</div>

JS

$(function () {
     $("#mod").click(function(){ 
        $('#navigate-away').modal('show');
     });
});

CSS

#mod{
    margin-top: 100px;
}

But there's no event for this in the documentation... There is a way to handle this? Any tip or advice would be appreciated.

If you need more info, let me know and i'll edit the post.

4

1 回答 1

3

在文档中,您可以使用显示的事件来了解动画何时完成:

“显示:当模式对用户可见时触发此事件(将等待 css 转换完成)​​。”

$('#myModal').on('shown', function () {
  // do something… 
})
于 2013-05-01T23:35:41.177 回答