Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working in Cleditor,
i want to insert a data from database when table is selected it works fine when
document load, but in partial view or ajax call in second time it does not work in editable mode, and also not able to display the details get from database.
JavaScript
 $("#edit_template").live('click', function () {
                $("#add_temp").show();//--> display the div inside 
//#teditor is textarea
                $("#teditor").cleditor({ width: 500, height: 470,
                    controls: "bold italic underline strikethrough subscript superscript | font size " +
                    "style | color highlight removeformat | bullets numbering | outdent " +
                    "indent | alignleft center alignright justify | undo redo | " +
                    "rule link image unlink | cut copy paste pastetext | print source", updateTextArea: "new text to set"
                })[0].clear().execCommand("inserthtml", area, null, null);
 $("#teditor").val(data.objtemplate.templatecontent);
});
Posted
Updated 11-Jul-12 0:05am
v2

I would suggest to use the live binding in the onload event of the page.
Because jquery's onready event will be fired only first time after each partial refresh it will not be called and binding of live will not occur.

So put your code under onload event and it will work.
 
Share this answer
 
I found the solution by myself after longtime....
options should be declared public...

my code is here
JavaScript
var options = {
               width: 500,
               height: 470,
               controls: "bold italic underline strikethrough subscript superscript | font size " +
                    "style | color highlight removeformat | bullets numbering | outdent " +
                    "indent | alignleft center alignright justify | undo redo | " +
                    "rule link image unlink | cut copy paste pastetext | print source"
           };



//partial view called in html code
<pre><div id="template"><% Html.RenderPartial("PVTemplate");%> </div>


//partial view
<div id="tarea">
               <%if (Model != null)
                    { %>
                 <%if (Model.objtemplatedetails != null)
                   { %>
                   <%-- <%=Html.TextAreaFor(model => model.teditor, new {id = "teditor"})%>--%>
                       <textarea id="teditor" style="width:500px"  name="inputtext"  rows="0" cols="0"><%=Html.Encode(Model.objtemplatedetails.First().txttemplatecontent)%></textarea>

                 <%}  %>

                <%if (Model.objtemplate != null)
                  { %>
                    <textarea id="teditor" style="width:500px"  name="inputtext"  rows="0" cols="0"><%=Html.Encode(Model.objtemplate.templatecontent)%></textarea>
               <%--   <%: Html.TextAreaFor(model=>model.objtemplate.templatecontent, new {Id = "teditor" }); %>--%>

                <%} %>
                 <%} %>

  </div>


//Add template fancy box
$("#add_template").live('click', function () {
              $('#txtemplatename').val('');
              $('#ddlsubject').val('');
              var editableText = '<textarea id="teditor" style="width:500px"  name="teditor"  rows="0" cols="0"></textarea>';
              $('#template').html(editableText);
              var editor = $("#teditor").cleditor(options)[0];
              //               var templateid = "";
          });


//In Edit template
var editableText = '<textarea id="teditor" style="width:500px"  name="teditor"  rows="0" cols="0">' + data.objtemplate.templatecontent + '</textarea>';
                         $('#template').html(editableText);
                         var editor = $("#teditor").cleditor(options)[0];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900