我想在用户点击删除按钮(输入类型=“提交”)时打开对话框,但没有任何反应,甚至没有JS错误。
代码:
$(function() {
$( "#dialog-confirm" ).dialog({
autoOpen: false,
resizable: true,
modal: true,
overlay: {
backgroundColor: '#000',
opacity: 0.5
},
buttons: {
"Delete": function() {
$.ajax({
type: "post",
url: "delete.php",
data: "eridTBD=" + eridTBD,
context: $( "h1" ).first(),
error: function(){
$( this ).after( "<p>no dice</p>" );
},
success: function( results ){
$( this ).after( results )
}
});
$( this ).dialog("close");
},
Cancel: function() {
$( this ).dialog("close");
}
}
});
$( ".delete_form input[name=delete]" ).click(function() {
$( "dialog-confirm" ).dialog( "open" );
return false;
});
});
有什么建议吗?
答案 0 :(得分:1)
错过了英镑符号:
$( "dialog-confirm" ).dialog( "open" );
应该是
$( "#dialog-confirm" ).dialog( "open" );