Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the textarea value from jQuery LineControl Editor?

Tags:

html

jquery

I'm using this jquery plugin to create a wysiwyg text editor,
I created a textarea where I want to display the text editor:

<textarea class="editor" rows="3" name="textEditor" id="textEditor"></textarea>

and then I called the jquery function:

<script type="text/javascript">
  $(document).ready( function() {
    $("#textEditor").Editor();                   
  });
</script>

Until now everything is working good, but when I wanted to know if the text is writed correctly or not by using this function:

function displayText(){
  alert($("#textEditor").val());
}

it gives me an empty text!
What am I missing ?

like image 842
SlimenTN Avatar asked Feb 10 '23 15:02

SlimenTN


2 Answers

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"));
}
like image 90
Rory McCrossan Avatar answered Apr 01 '23 09:04

Rory McCrossan


Right!!!

There two methods to get and set text.

 $("#TextEditorID").Editor("setText", "TextInput")); 
 $("#TextEditorID").Editor("getText));
like image 35
Kamlesh Avatar answered Apr 01 '23 10:04

Kamlesh