モーダルウィンドウには、「続行」ボタンがあります。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();
}
}
});
}