因此,我一直在与Discover Meteor合作,但遇到了问题。

我试图将在summernote中输入的内容插入到mongo中,但是我遇到了一些问题。

post_submit.html

<div class="form-group {{errorClass 'content'}}">
     <textarea class="form-control" name="content" id="summernote"></textarea>
</div>


post_submit.js

var post = {
  url: checkURLPrefix( $(e.target).find('[name=url]').val() ),
  title: $(e.target).find('[name=title]').val(),
  content: $(e.target).find('[name=content]').val()
};


lib / posts.js(提交时会显示“匹配失败”错误)

meteor.methods({
  postInsert: function(postAttributes) {
    check(this.userId, String);
    check(postAttributes, {
      title: String,
      url: String,
      content: function(content){$('[name=content]').html($('#summernote').code());}
    });


我试过content: String将数据输入到mongo中。可以,但是当我尝试将{{content}}加载到post_page.html文件中时,它将仅显示未呈现的HTML代码。 {{{content}}}会显示正确呈现的内容,但会基于投票使分类系统的功能混乱。

我在这里真的迷路了,希望我能尽快找到解决方案。

先感谢您!

EDIT1:这是我的post_page.html,当我插入内容时会看到:字符串并使用{{content}}加载

<template name="postPage">
  {{> postItem}}

    <div class="col-md-12" style="background:blue;">

        {{content}}

    </div>

  <ul class="comments">
    {{#each comments}}
      {{> commentItem}}
    {{/each}}
  </ul>

  {{#if currentUser}}
    {{> commentSubmit}}
  {{else}}
    <p>Please log in to leave a comment.</p>
  {{/if}}
</template>


http://i.imgur.com/Fm0CXAN.png

最佳答案

首先:您应该在div中而不是textarea中使用summernote。

post_submit.js中,您必须这样保留它:

var post = {
    ...
    content: $(e.target).find('#summernote').code()
};


在您的post_page.html中使用三括号,因为它是HTML。

<div class="col-md-12" style="background:blue;">
    {{{content}}}
</div>

09-25 17:16
查看更多