私のMVC 3アプリでは、リッチテキストの編集にCKeditorを使用しています。今はHTMLタグでテキストをDBに保存する必要があります。Javascript機能が起動していませんか?
問題は「保存」ボタンをクリックしても何も起こりません。
アラートは未定義です。
ビュー:
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
@Html.DropDownListFor(model=>model.Id, Model.Texts)
<div class="editor-field">
@Html.TextAreaFor((model => model.Text), new { @Id = "editor1" })
@Html.ValidationMessageFor(model => model.Text)
</div>
<script type="text/javascript">
CKEDITOR.replace('editor1');
</script>
<script type="text/javascript">
var editor_data1 = $('editor1').val();
var editor_data = editor_data1.getHtml();
var url = '@Url.Action("EditText", "Admin")';
var data = { commentText: editor_data };
function Save() {
alert(editor_data);
$.post(url, data, function(result) {
});
};
$('#Id').change(function() {
var selectedText = $(this).val();
if (selectedText != null && selectedText != '') {
$.getJSON('@Url.Action("Text","Admin")', { Id: selectedText }, function (text) {
// var textSelect = $('#Text');
// textSelect.empty();
// $("#Text")[0].value = text;
CKEDITOR.instances['editor1'].setData(text);
// $.each(text, function (index, employee) {
// textSelect.append($('<option/>', {
// value: employee.Value,
// text: employee.Text
//// }));
// });
});
}
});
</script>
</fieldset>
<p>
<input type="button" value="Save" onclick="Save()"/>
</p>
}
はすべてをttryed、まだ...アラートは未定義同じ返し、私はあなたに多分、人々はCKエディタ – Timsen
@Timsenからデータをretriveインターネット上の任意の場所を見つけるカントあなたのコードにいくつかの他のエラーがあります。あなたのjavascriptデバッグコンソールを見てください。あなたが投稿したこの非常に単純なコードスニペットでわかるように、私は非常に多くの問題を発見しました。あなたは私に今CKEDITORをダウンロードさせ、あなたのための完全な例を書いてくれますか?私はちょうど映画を見るために準備していた:-) –
私はjavascriptingでawefullです(ちょうどそれを学び始めた)。 #idはドロップダウンリスト項目のIDなので、その部分は正常に動作しています。 – Timsen