对于我的生活,当单击Yes按钮时脚本不会执行时,我无法解决问题?
控制台中没有记录任何内容。
有人可以帮忙吗?! :)
小提琴在这里:http://jsfiddle.net/MCam435/NYWg2/2/
HTML:
<div id="reqtalkdialog" title="Confirmation Required">
Would you like to request contact?
</div>
<div id="reqtalk100006" style="display:block"><a href="#" class="reqtalk" id="100006">
<span class="reqtalk_b"> + Talk </span></a></div>
jQuery的:
$("#reqtalkdialog").dialog({
autoOpen: false,
modal: true,
buttons : {
"Yes" : function() {
var element = $(this);
var I = element.attr("id");
var info = 'id=' + I;
$.ajax({
type: "POST",
url: "resource/talkrequest.php",
data: info,
success: function(){}
});
$("#reqtalk"+I).hide();
$("#talking"+I).show();
return false;
$(this).dialog("close");
},
"Cancel" : function() {
$(this).dialog("close");
}
}
});
$(".reqtalk").on("click", function(e) {
e.preventDefault();
$("#reqtalkdialog").dialog("open");
});
答案 0 :(得分:2)
在关闭对话框之前,您将返回false。
删除该行,它有效:http://jsfiddle.net/A6TbN/
$("#reqtalkdialog").dialog({
autoOpen: false,
modal: true,
buttons : {
"Yes" : function() {
var element = $(this);
var I = element.attr("id");
var info = 'id=' + I;
$.ajax({
type: "POST",
url: "resource/talkrequest.php",
data: info,
success: function(){}
});
$("#reqtalk"+I).hide();
$("#talking"+I).show();
// return false;
$(this).dialog("close");
},
"Cancel" : function() {
$(this).dialog("close");
}
}
});
$(".reqtalk").on("click", function(e) {
e.preventDefault();
$("#reqtalkdialog").dialog("open");
});