我需要一些非常基本的帮助。基本上,我试图创建一个模态确认对话框,我已经完成了大部分工作。简单地说,这是一个对话,询问“你确定吗?”两个按钮“是”和“否”
<script>
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Yes": function() {},
"No": function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
当我点击“是”时,该框关闭并完成运行我想要的脚本? 这可能是一件新事物,但我正在学习,而不是以任何特定的顺序
更新1
新代码:
$('#stats_ensaves').click(function(){
$('#thedialog').dialog('open');
return false;
});
$('#thedialog').dialog({
autoOpen: false,
width: 300,
buttons: {
"Confirm": function(){
$("#stats_ensaves").dialog("open");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
stats_ensaves就在这里:<span class="playerstat">Energy Saves: </span>
<span id="stats_ensaves"><a href="http://www.galatium.net/account.php?onnow=N" id="link"><b>ON</b> (7 left)</a></span>
我的新问题是:为什么不将确认按钮链接到该链接?
答案 0 :(得分:0)
...
buttons: {
"Yes": function() {
// some code here when yes was clicked
$( this ).dialog( "close" );
},
"No": function() {
$( this ).dialog( "close" );
}
...
答案 1 :(得分:0)
$(".confirm").click(function(e) {
e.preventDefault();
var targetUrl = $(this).attr("href");
var $dialog-confirm = $('<div></div>').
html("<p>Are you sure?</p>").
dialog({autoOpen: false,
title: 'Please Confirm',
buttons : {
"Yes" : function() {....},
"No" : function() {....}
},
modal: true
});
$dialog-confirm.dialog("open");
});
答案 2 :(得分:0)