[英]Using summernote with meteor (Discover Meteor)
因此,我一直在与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: String
。 可以,但是当我尝试将{{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>
首先:您应该在div
使用summernote,而不要在textarea
。
在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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.