Can someone help me with the default textarea
name value for Summernote? The editor looks correct on the page (I can modify text using the interface) but POST isn't working based on my understanding.
I've tried a variety of POST variables but none of them seem correct. Examples are summernote
, note-codable
and text-area
. The last two came from summernote.js. Jquery isn't something that I have much experience with, so please baby-step me.
These are what I am using.
$('#summernote').summernote({height: 300});
var sHTML = $('#summernote').code();
and
<div name="summernote" id="summernote"><?php echo $news_body; ?></div>
I've also tried the lines below separately in an attempt to change the textarea name to content
:
var sHTML = $('#summernote').code();
$('#summernote').code();
var content = $('textarea[name="content"]').html($('#summernote').code());
$('textarea[name="content"]').html($('#summernote').code());
var sHTML = $('textarea[name="content"]').html($('#summernote').code());
var textareaValue = $("#content").code();
$("summernote").code(html);
The textarea doubles as the container for the summernote editor, but you could just as easily use a hidden textarea, and use a div for the summernote container. To get the data from summernote to the textarea you need to call the . code() function on the summernote element at the time of the POST.
The Summernote Editor is a free & open-source super simple WYSIWYG editor based on Bootstrap & jQuery. It is a JavaScript library that can be useful to build the WYSIWYG editors online.
You can disable editor by API. $('#summernote'). summernote('disable');
This turned out to be a very simple fix. The root of the confusion is the documentation that says to use a div. Just use a text-area instead. Although summernote creates a text-area dynamically, do it anyway. It'll work.
I found a working example of using Summernote with php doing a form POST here.
It is a bit convoluted so I will explain what is going on.
First you need to add a textarea that will be the container for the contents of the post. In the example there is one named "content". The textarea doubles as the container for the summernote editor, but you could just as easily use a hidden textarea, and use a div for the summernote container.
To get the data from summernote to the textarea you need to call the .code() function on the summernote element at the time of the POST. The example does this by setting the onsubmit handler to a function (named "postForm" in the example) that finds the summernote element, gets the encoded input, and sets the encoding string as the html of the textarea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With