在我的模态窗口中,我有一个“继续”按钮。虽然我可以通过使用 simplemodal-close 类分配按钮来关闭模式,但我无法让它调用我的函数。我从网站上的简单演示中整理了这段代码。
按钮:
<a href="#" class="simplemodal-close" onClick="closePopup()"><img src="bell/images/button_understand.gif" width="116" height="49"></a>
的JavaScript:
$(document).ready(function() {
function showPopups(){
var e = document.getElementById('hirpopup');
$('#hirpopup').modal({
opacity:80,
overlayCss: {backgroundColor:"#fff"}
});
e.style.display = 'block';
return false;
}
function closePopup(){
var e = document.getElementById('hirpopup');
e.style.display = 'none';
confirm(function () {
sameWindow(this.form);
});
}
function confirm(callback) {
$('#hirpopup').modal({
onShow: function () {
var modal = this;
// call the callback
if ($.isFunction(callback)) {
callback.apply();
}
}
});
}
});
任何想法,因为我对 jQuery 很陌生,对 simplemodal 完全陌生。
编辑:我已经按如下方式更新了我的 javascript,但是它仍然没有执行我的功能。我收到了 1 的警报,以及其中包含该功能的警报,但没有别的。
$(document).ready(function(){
$("#close").css("cursor", "pointer");
$('#next').click(function(){
var e = document.getElementById('hirpopup');
$('#hirpopup').modal({
opacity:80,
overlayCss: {backgroundColor:"#fff"}
});
e.style.display = 'block';
return false;
});
$('#close').click(function(){
var e = document.getElementById('hirpopup');
e.style.display = 'none';
confirm(function () {
sameWindow(this.form);
});
});
});
function confirm(callback) {
alert("1");
alert(callback);
$('#hirpopup').modal({
onShow: function () {
alert("2");
var modal = this;
// call the callback
if ($.isFunction(callback)) {
alert("3");
callback.apply();
}
}
});
}