在确认消息 onclick() 时使用引导程序
Using bootstrap on confirm message onclick()
我是引导程序的新手,我有用于消息确认的代码。
如何使用下面的代码放置我的onclick()
?
$("#myModal").on("show", function() { // wire up the OK button to dismiss the modal when shown
$("#myModal a.btn").on("click", function(e) {
console.log("button pressed"); // just as an example...
$("#myModal").modal('hide'); // dismiss the dialog
});
});
$("#myModal").on("hide", function() { // remove the event listeners when the dialog is dismissed
$("#myModal a.btn").off("click");
});
$("#myModal").on("hidden", function() { // remove the actual elements from the DOM when fully hidden
$("#myModal").remove();
});
$("#myModal").modal({ // wire up the actual modal functionality and show the dialog
"backdrop" : "static",
"keyboard" : true,
"show" : true // ensure the modal is shown immediately
});
引导框的网页:
网页(图片)
onclick() 输入:
<input type='submit' name='actualiza_noticia' class='button' onClick="" value='Atualizar notícia'>
>您可以使用 jQuery 函数$(elem).modal('show')
函数或 Bootstrap html 数据属性:
使用数据属性:
<input type='submit' data-toggle="modal" data-target="#myModal" name='actualiza_noticia' class='button' value='Atualizar notícia' >
使用 Jquery 函数:
<input onclick="$('#myModal').modal('show')" type='submit' name='actualiza_noticia' class='button' value='Atualizar notícia' >
这些 shuold 都会触发您的事件,尽管'show'
事件'shown.bs.modal'
符合 Bootstrap 3
$("#myModal").on('shown.bs.modal', function() { // wire up the OK button to dismiss the modal when shown
$("#myModal a.btn").on("click", function(e) {
console.log("button pressed"); // just as an example...
$("#myModal").modal('hide'); // dismiss the dialog
});
});
在此处阅读有关引导模式的更多信息。
根据报告您的html的图像,我的建议是:
- 将
$("#myModal").on("show", function() {
更改为'$("#myModal").on("display.bs.modal", function() { - 将
$("#myModal a.btn").on("click", function(e) {
更改为$("#myModal button.button.btn.btn-primary").on("click", function(e) {
- 将
$("#myModal").on("hide", function() {
更改为$("#myModal").on("hide.bs.modal", function() {
- 将
$("#myModal a.btn").off("click");
更改为$("#myModal button.btn.btn-primary").off("click");
有关详细信息,请参阅引导模式
$(function () {
$("#myModal").on("shown.bs.modal", function() { // wire up the OK button to dismiss the modal when shown
$("#myModal button.btn.btn-primary").on("click", function(e) {
console.log("button pressed"); // just as an example...
$("#myModal").modal('hide'); // dismiss the dialog
});
});
$("#myModal").on("hide.bs.modal", function() { // remove the event listeners when the dialog is dismissed
$("#myModal button.btn.btn-primary").off("click");
});
$("#myModal").on("hidden", function() { // remove the actual elements from the DOM when fully hidden
$("#myModal").remove();
});
$("#myModal").modal({ // wire up the actual modal functionality and show the dialog
"backdrop" : "static",
"keyboard" : true,
"show" : true // ensure the modal is shown immediately
});
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<!-- dialog box -->
<div class="modal-body">
<button type="btn btn-default" class="close" data-dismiss="modal">×</button>
Hello world!
</div>
<!-- dialog buttons -->
<div class="modal-footer">
<button type="btn btn-default" class="btn btn-primary">OK</button>
</div>
</div>
</div>
</div>
相关文章:
- Html引导程序警报自动关闭困难
- 引导程序:在导航栏中,显示悬停在单个位置的基于Li Link的不同内容
- Twitter引导程序Typeahead-Id&标签
- 引导程序崩溃一次只能看到一个
- 引导程序/基础堆叠行/列
- 如何保持引导程序下拉复选框列表下拉
- .aspx页面上引导程序中的动态选项卡
- 菜单栏class=活动引导程序主题无法正常工作
- 为什么引导程序下拉菜单只有在包含bootstrap-responsive.css时才起作用
- 如何在引导程序元素的顶部添加掩码
- 如何平滑地设置twitter引导程序进度条的动画
- 如何在模式弹出窗口中使用引导程序日期和时间选择器
- 引导程序转盘不工作:堆叠图像(使用rails)
- datepicker引导程序再次初始化
- Nano Scroller在引导程序DropDown和Model Box中不起作用
- 使用引导程序确认发布请求
- 在更新面板中使用引导程序确认
- 使用引导程序验证程序进行验证后,停止表单提交并打开引导模式(确认对话框)
- 引导程序3:删除确认对话框无效
- 在确认消息 onclick() 时使用引导程序