我怎樣才能得到用戶的輸入,在這裏是一種方法來輸出或編碼?CkEditor:有沒有一種方法來輸出輸入內容
現在我能做的就是
var content = $('#cke_ckeditor1 iframe').contents().find('.cke_show_borders').clone();
我怎樣才能得到用戶的輸入,在這裏是一種方法來輸出或編碼?CkEditor:有沒有一種方法來輸出輸入內容
現在我能做的就是
var content = $('#cke_ckeditor1 iframe').contents().find('.cke_show_borders').clone();
有一個返回編輯器的內容的方法 - editor.getData()
- 見documentation。
您可以在CKEDITOR.instances
對象中找到編輯器實例。
我使用了itextsharp的引用來使用ckeditor。
在HTML
<%= Html.Hidden("EditECurrentComplainText")%>
這裏一個div我用包含textArea並轉換它CKEDITOR,然後置於該CKEditor的的值到一個隱藏字段內聲明一個隱藏的文本字段。使用下面的語句
$("#EditECurrentComplainText").val(CKEDITOR.instances["EditCurrent_ComplainCK"].getData());
,最後用這個hiddentext領域的內容,我期望的輸出/輸入的CKEditor的
<div id="EditECurrentComplain_ckEditor">
<%= Html.TextAreaFor(model => model.Current_Complain, new { rows = "10", id = "EditCurrent_ComplainCK" })%>
<%= Html.ValidationMessageFor(model => model.Current_Complain)%>
<% if (Model.Current_Complain != "")
{ %>
<script type="text/javascript">
jQuery(document).ready(function() {
CKEDITOR.replace('EditCurrent_ComplainCK');
});
</script>
<%} %>
</div>
獲取內容到隱藏文本框。
謝謝。
你不需要所有這些。如果你通過替換textarea來創建CKEditor,那麼你所需要的只是'editor.updateElement()'([docs](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-updateElement))和那麼textarea將包含編輯器的內容。 – Reinmar
你的意思是我可以使用像textAreaID.updateElement()? –
沒有。如果你有textarea id,那麼'CKEDITOR.instances。 .updateElement()'。 –
Reinmar