hh54188
hh54188

Reputation: 15656

CkEditor: is there a method to output the input content

How can I get the user's input, is here a method to output or encode?

Now what I can do is

var content = $('#cke_ckeditor1 iframe').contents().find('.cke_show_borders').clone();

Upvotes: 2

Views: 846

Answers (2)

Rashedul.Rubel
Rashedul.Rubel

Reputation: 3584

I used reference of itextsharp to use ckeditor.

Declare a hidden text field in html

<%= Html.Hidden("EditECurrentComplainText")%>

Here inside a div i used a textArea and converted it to ckeditor and then placed value of that ckeditor into a hidden field.

<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>

get content of ckeditor into hidden textfield using the following statement

$("#EditECurrentComplainText").val(CKEDITOR.instances["EditCurrent_ComplainCK"].getData());

and finally used this hiddentext field content as my desired output/input.

Thanks.

Upvotes: 0

Reinmar
Reinmar

Reputation: 22023

There's a method that returns editor's content - editor.getData() - see documentation.

You can find editor instance in CKEDITOR.instances object.

Upvotes: 3

Related Questions