欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

show.bs.modal 的情况

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">Open modal for @mdo</button>
1)data-toggle="modal" 当然会触发执行 show.bs.modal 事件 event.relatedTarget是有值

$('#exampleModal').modal('show')
2)在jquery中执行
$('#exampleModal').modal('show') 当然
也会触发执行 show.bs.modal 事件 但是 event.relatedTarget是没有值无值

(
'#exampleModal').on('show.bs.modal', function (event) {
  var button = $(event.relatedTarget) // Button that triggered the modal
  var recipient = button.data('whatever') // Extract info from data-* attributes
  // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
  // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
  var modal = $(this)
  modal.find('.modal-title').text('New message to ' + recipient)
  modal.find('.modal-body input').val(recipient)
})
普通分类: