如何从函数调用Jquery打开模态
How to Open Modal from Function Call Jquery
我从Bootstrap获得了此模态当我添加按钮若要成功打开,但我真正需要的是从函数调用中自动打开这个模态我的实验是:
<button id="RenewCollerctorDateID" class="btn btn-success" style="width: 10%; display: inline;
padding-right: 10px; float: left;" onclick="RenewCollectorDatePeriod();">renew</button>
我的JavaScript是
function RenewCollectorDatePeriod() {
// AreYOuSureRenew();
var EmpID = $("#<%=ddlFilterCollector.ClientID%>").val();
if (EmpID == -1) {
alert("please select one ")
}
else {
alert(EmpID);
GetCollectorInfo(EmpID);
}
}
然后:
function GetCollectorInfo(EmpID) {
// AreYOuSureRenew();
$.ajax({
type: "POST",
url: "UnloadingCalendar.aspx/GetCollectorInfo",
data: JSON.stringify({ EmpID: EmpID }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
alert(result.d);
AreYOuSureRenew();
},
error: function (msg) {
alert(msg.d);
},
complete: function () {
}
})
}
function AreYOuSureRenew() {
alert("opened");
$('#EnsureModal').modal('show');
}
这是我的模式
<div class=" modal fade" id="EnSureModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Do ypu need change </h4>
</div>
<div class="modal-body">
<p>Are u sure from </p>
<label id="FromDate"></label>
<p>To</p>
<label id="ToDate"></label>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">no</button>
<button type="button" class="btn btn-default" data-dismiss="modal">yes</button>
</div>
</div>
</div>
</div>
注意:当我在文档中添加$("#EnSureModal").modal('show');
时。Ready-it在页面加载时安抚并在函数调用时再次出现,我如何使它只出现在函数调用中
我阅读了您的代码,发现您没有正确使用引导程序,而且您编写的脚本也不正确。看看这个。这可能会对你有所帮助。
脚本:
$(document).ready(function(){
$("#fireme").click(function(){
$("#EnSureModal").modal();
});
});
HTML:
<button id="fireme" class="btn btn-default">Fire me up!</button>
<div class="modal fade" id="EnSureModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Do ypu need change </h4>
</div>
<div class="modal-body">
<p>Are u sure from </p>
<label id="FromDate"></label>
<p>To</p>
<label id="ToDate"></label>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">no</button>
<button type="button" class="btn btn-default" data-dismiss="modal">yes</button>
</div>
</div>
</div>
</div>
小提琴
相关文章:
- 使用模态对话框(JQuery)编辑函数
- jQuery模态弹出的行为类似于确认和警报对话框
- 使用jQuery防止模态内部的元素关闭模态
- 使用一个 jquery 代码关闭多个模态
- 如何使用jquery关闭模态窗口,通过模拟模态's关闭按钮
- 使用 php/jquery 动态更新单个模态
- jquery在 asp.net 中使用模态进行确认
- 更改“;模态“;类似Jquery“;切换”;
- 如何从函数调用Jquery打开模态
- jquery模态对话框通过id获取输入类型text的值
- jQuery带有文本输入的模态消息
- ASP.net按钮单击时不使用Jquery模态对话框激发
- Jquery 关闭模态问题
- 如何在 jquery 中浮动模态窗口
- 当文本值大于$40时为模态-jQuery
- 获取HTML表中的ROW ID,以便在模态jQuery中使用;PHP
- 带有“确认”的奇怪行为;模态jquery
- 禁用隐藏模态窗口时,点击退出模态jquery
- 单击显示模态jquery
- 为什么我的模态jQuery对话框打开多次