引导模式加载事件
Bootstrap modal onload event
引导模式是否有onload事件?我想在打开模态时调用一个http GET请求,用rest api中的数据填充模态。我在模态中有一个表单,并且在表单的onload事件上调用了GET函数,但它不起作用。
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Agent details:</h4>
</div>
<div class="modal-body">
<form onload="getData()" style= "font-size: 16pt">
根据文档,您可以收听显示或显示的事件。
来自文件:
show.bs.model=>调用show实例方法时,此事件会立即激发。
shown.bs.modal=>当模态对用户可见时(将等待CSS转换完成),会触发此事件。
$('#myModal').on('show.bs.modal', function () {
// do something…
})
我发现最好的方法是将onclick属性添加到调用modal的html元素中。
<button type="button" onclick="PopulateAddModal()" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#AddModal">Add</button>
然后在您的javascript中。。
function PopulateAddModal() {
//do stuff here...
}
这将确保您的代码在调用模态后立即运行。否则,在模态完全完成其"淡入"动画之前,javascript代码将不会运行。
相关文章:
- 召回窗口加载事件 - javascript
- 仅加载事件序列
- Jquery onclick事件加载XML的特定节点
- jQuery事件加载
- Javascript:js 不会在事件加载时执行
- PhantomJS - 从单击事件加载的内容不会加载到 DOM
- 事件加载 jQuery 和 YouTube API
- 如何在单击时运行事件加载
- 将事件加载到日历中
- zurbfoundation和ajax上的事件加载了内容
- Jquery 不绑定事件加载
- 如何模拟按键事件加载
- jQuery 事件加载在 onFinish 执行
- Xhr 上传事件加载问题
- Opera用户脚本事件"加载"并不总是有效
- 事件加载并准备就绪,但未触发
- 用javascript onclick事件加载并播放gif
- Aurelia -事件加载/惰性加载图像
- 复选框onclick事件加载,就好像选中了一样
- 当am使用jquery加载事件加载图形页面时,外部页面Morris图表未加载