I am using Codeiginter with Summernote on front end - Now In a form, when some fields are empty, the same page loads with validation checking. I am using the following JS and CI code:
$(window).load(function(){
<?php if(isset($article['text']))
{
?>
$('#summernote').code('<?php echo $article['text']; ?>');
<?php } else { ?>
$('#summernote').code('<?php echo $_POST['contents']; ?>').text();
<?php } ?>
});
Now the issue is when say, validation fails, the above code populates the Summernote editor with RAW HTML instead of formatted HTML as it should
This is an example of my first post Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque commodo eros a enim. Aenean imperdiet. Cras sagittis.
Nam at tortor in tellus interdum sagittis. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Etiam ut purus mattis mauris sodales aliquam. Curabitur blandit mollis lacus. Phasellus tempus.
Any ideas why is this so? I have tried .val and .html - but they don't work. Kindly help.
.text()
from your else block and try again to see if it works. – Kamran