简体   繁体   English

在流星上使用summernote(发现流星)

[英]Using summernote with meteor (Discover Meteor)

So, I've been working with Discover Meteor, and I'm having problems. 因此,我一直在与Discover Meteor合作,但遇到了问题。

I'm trying to insert what content inputted in summernote into mongo but I'm having a few problems. 我试图将在summernote中输入的内容插入到mongo中,但是我遇到了一些问题。

post_submit.html post_submit.html

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

post_submit.js 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 (will say Match Failed error when submitting) 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());}  
    });

I've tried content: String to input the data into mongo. 我已经尝试过content: String将数据输入到mongo的content: String It would work but when I tried to load {{content}} in the post_page.html file, it would just show the unrendered HTML codes. 可以,但是当我尝试将{{content}}加载到post_page.html文件中时,它将只显示未渲染的HTML代码。 {{{content}}} would show to content properly rendered but would mess up the functionality of the sorting system based on votes. {{{content}}}会显示正确呈现的内容,但会根据投票结果使分类系统的功能混乱。

I'm really lost here and I wish I could find a solution soon. 我在这里真的迷路了,希望我能尽快找到解决方案。

Thank you in advance! 先感谢您!

EDIT1: Here is my post_page.html and what I see when I insert content: String and load with {{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 http://i.imgur.com/Fm0CXAN.png

First: you should use summernote in a div , not a textarea . 首先:您应该在div使用summernote,而不要在textarea

And in post_submit.js you have to leave it like this: post_submit.js您必须像这样保留它:

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

In your post_page.html use triple brackets, because its HTML. 在您的post_page.html使用三括号,因为它是HTML。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM