2

I insert data using summernote text editor. When i render this in my page than it is showing like <p>somthing</p>. And i want this as plain text.

JS Code

exports.Blog = function (req, res) {
    if (req.session.Id != null) {
        connection.init();
        connection.query("select * from blog_posts where user_id=? order by date_created desc", [req.session.Id], function (reqest, row, fields) {
            res.setHeader("Content-type", "text/html");
            res.render('Blog', { rows: row });
        });
    }
    else {
        res.render('login');
    }
};

ejs code

<%var result=rows%>
<%
  for(var i=0;i<result.length;i++)
  {
%>
  <div class="well">
    <div id="desc-<%=result[i].Id%>"></div>
    <script type="text/javascript">
       $(function () { 
          var desc='<%=result[i].description%>';
          console.log(desc);
          $('#desc-<%=result[i].Id%>').html(desc);
       });
    </script>
  </div>
<%
 }
%>
3
  • did you see the console.log(JSON.stringify(row)); ,, is there data or not? Commented Jul 19, 2014 at 6:38
  • When i use console.log(JSON.stringify(desc)); than result is remains same @MuhammadAli Commented Jul 19, 2014 at 6:40
  • I'm not node.js guy, but last answer in this question might help. Commented Jul 19, 2014 at 6:42

2 Answers 2

1
<%var result=rows%>
<%
  for(var i=0;i<result.length;i++)
  {
%>
  <div class="well">
    <div id="desc-<%-result[i].Id%>"><%-result[i].description%></div>

  </div>
<%
 }
%>
Sign up to request clarification or add additional context in comments.

Comments

0

why are you generating script to insert html you can directly put description into div.

<%var result=rows%>
<%
  for(var i=0;i<result.length;i++)
  {
%>
  <div class="well">
    <div id="desc-<%-result[i].Id%>"><%=result[i].description%></div>

  </div>
<%
 }
%>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.