E A
E A

Reputation: 11

Issue with formating while using quill and #editor element

So I've been playing around with quill for a day or two. Currently building a website to learn more about javascript and ajax. But the formatting using quill isn't really working that smooth..

I started to read a little here but those solutions didn't get me that far. I'm appending the result to a hidden textarea. Here I got 2 options. Taking the entire "#editor" element - Which works the best. It gives me the correct formatting and everything.

Problem is that I'm getting "Everything" - Including the tooltip div, so the posted information comes with an input box as well as the "ql classes".

So I tried to add "ql-editor" as well and if I do that, I get the correct text without the divs - But the formatting is lost instead..

Anyone know what I'm doing wrong?

Code:

<div class="content-div">
    <div class="article_div">
    <h2>Add new article</h2>
    <form action="test.php" method="post" id="news_box">
    <div id="editor"></div>
    <textarea name="test" style="display:none" id="hiddenArea"></textarea>
<input type="submit" value="Done">
</form>
</div>
</div>
</div>
</div>

<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script>
  var quill = new Quill('#editor', {
    theme: 'snow'
  });
</script>
<script>
$("#news_box").on("submit",function(){
$("#hiddenArea").val($("#editor .ql-editor").html());
})
</script>

Upvotes: 0

Views: 579

Answers (1)

E A
E A

Reputation: 11

I'm soooo sorry for taking up anyone's time.. Found a solution..

After posting the info to the php page - I added a variable.

<?php
$news_text = "<pre>";
$news_text .= $_POST['test'];
$news_text .= "</pre>";

echo $news_text;
?>

Upvotes: 1

Related Questions