0

好的,我已经为此工作了一段时间,我快要拔掉头发了。这是场景。我正在创建一个讨论板,使用 AJAX 调用发布表单,当用户提交表单时,我希望触发一个包含警告和评论的对话框,以便他们查看并在需要时继续编辑。

问题:我无法启动该死的对话框。我已经尝试过这里发布的大多数 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.

好的,让我感谢所有做到这一点的人。我的脸皮也很厚,因为我搞砸了其他垃圾,或者我用过的糟糕的形式。我正在尝试使用好习惯。

4

0 回答 0