2

いくつかの「解決策」を見つけましたが、何もうまくいかないようです。Malsup の jquery フォーム プラグインを使用して、POST 経由でフォーム データを送信しています。フォーム要素の 1 つが nicEdit ボックスです。これが私のコードです:

html:

<div class="leftaligned">   
<h1>Add News:</h1>
<form enctype="multipart/form-data" id="addnewsform" action="addnewscode.php" method="POST">
<input type="hidden" name="isnewnews" value=1 />
<div class="missinginfo">
Please add a title and some content!
</div>
<h2>Title:</h2>
<input type="text" size="50" id="newtitle" name="newtitle">
<h2>Content:</h2>
<textarea style="width:590px; height:300px;" id="newcontent" name="newcontent"></textarea>
<br>
<div id="contentbuttons">
<input type="submit" value="Add News" class="submitnews" style="float:left;" /></form>
<input type="button" value="Cancel" onclick='parent.$.colorbox.close(); return false;'/>
</div>

送信ボタンがクリックされたときに現在呼び出されているものは次のとおりです。

<script>
$(document).ready(function() { 
var options = {

    beforeSubmit: function(arr, $form, options) {
        var title = document.getElementById("newtitle").value;
        var content = document.getElementById("newcontent").value;
        alert(content);
        var title = document.getElementById("newtitle").value;
        if(title == "" || content == "") {
            parent.$.fn.colorbox.resize({height:635});
            $(".missinginfo").show();
            setTimeout(function()     {$(".missinginfo").hide();parent.$.fn.colorbox.resize({height:610});},2000);
            return false;
        }

    },

    success:       showResponse  
}; 

$('#addnewsform').submit(function() { 
    $(this).ajaxSubmit(options); 

    return false; 
});

function showResponse(responseText, statusText, xhr, $form)  { 
    parent.onAddNewsSuccess();
}  
});
</script>

私の #newcontent テキスト エリアは nicEdit ボックスです。

アラート (コンテンツ) には何も表示されないので、nicEdit ボックス内のテキストを送信するために他に何かする必要があることがわかります。私は何が欠けていますか?

4

1 に答える 1

0

(質問の編集で回答。コミュニティ wiki の回答に変換。質問への回答が質問自体に追加された場合の適切なアクションは何ですか? を参照してください。 )

OP は次のように書いています。

気にしないで、次を使用して解決しました:

    beforeSerialize: function($form, options) {
    nicEditors.findEditor('newcontent').saveContent();
},
于 2015-02-07T18:45:32.893 に答える