jQuery line control HTML editor | Post data to server

|
| By Webner

In jQuery line-control editor, values written inside writing space (div) do not get posted to the server by default. This is because although we create textarea while coding, at run time a DIV is created in which user writes. Editor.editor is the Id of div at runtime. On submit we need to get value typed in the div and post it explicitly:

Below is the example of code in Javascript and HTML :

<script>
$(document).ready(function() 
{
  $("#txtEditor").Editor();
});
			
$(function()
{
  $('#save').click(function () 
  {
   //get text in div and assign to textarea
   var str = $( '#editor2 .Editor-editor' ).text();
   $('#txtEditor').val(str);
  });
});
</script>

<div class="container-fluid" id="editor2">
	<div class="row">
		<div class="container">
			<div class="row">
				<div class="col-lg-12 nopadding">
<textarea id="txtEditor" name="notes"></textarea>
				</div>
			</div>
		</div>
	</div>
</div>

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Web development or any other software development assistance please contact us at webdevelopment@webners.com

One comment

  1. From the documentation of that plugin on Github, you need to use the getText option to retrieve the value of the editor. Try this:

    function displayText(){
    alert($(“#textEditor”).Editor(“getText”));
    }

Leave a Reply

Your email address will not be published. Required fields are marked *