[英]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.