好的,我已经做了一段时间了,而且我已经接近拔头发了。这是场景。 我正在创建一个讨论板,使用AJAX调用发布表单,当用户提交表单时,我希望触发一个带有警告及其注释的对话框,以便让他们查看并在需要时继续编辑。 / p>
问题:我不能让frickin'对话框开火。我已经尝试了这里发布的大多数jQuery对话框答案,但没有一个有效。
我在这里发布主要代码,但如果需要,我会发布整个页面。我正在使用ckEditor,这个表单最初是从AJAX调用本身调用的。
以下是相关代码。
$('#postComment_' + id).click( function() {
// Warn the user about submitting. Let them review their comment.
CKupdate()
$('#confirmSubmit').dialog("destroy");
var commentTitle = $('#commentSubject_' + id).val();
// This is the warning dialog that isn't working!
var commentBody = CKEDITOR.instances['comment_' + id].getData();
var NewDialog = $('<div>You are about to submit your comment.</div>');
// This will be where the user content will be. I stripped it out until I can get a simple warning to show.
$(NewDialog).dialog({
modal: true,
autoOpen: false,
buttons: {
'Submit': function() {
$(this).dialog('close');
// Just close and submit.
$('#discussionComment_' + id).ajaxForm({
beforeSend: function() {
$('#discussionComment_' + id + ' input:submit').html('Sending...');
$('#newEntry').attr('id', '');
},
success: function(data) {
$('#commentBox_' + id).after(data);
$('#discussionComment_' + id).remove();
$('#discussionComment_' + id).hide('puff', function() { $(this).remove() }, 'fast');
$('#content_' + id + ' a.remove').removeClass('remove').addClass('respond').html('Respond');
$('.expand').show();
window.location + $('#newEntry');
$('#newEntry').children().effect("highlight", {}, 3000);
},
error: function () {
alert('There was a problem posting your comment. Please try again.');
}
}); // Form submit
},
'Edit': function() {
$(this).dialog('close');
return false; // Don't submit the form.
}
}
});
return false;
});// Click to submit form.
好的,我要感谢任何一位做到这一点的人。 我也很厚脸皮,因为其他的废话我搞砸了,或者我用过的糟糕的形状。我正在努力养成良好的习惯。