gpt4 book ai didi

javascript - Meteor更新到0.8.0后文本编辑器不显示内容

转载 作者:行者123 更新时间:2023-12-02 17:32:57 26 4
gpt4 key购买 nike

我最近集成了SimditorMeteor :

post_submit.html:

Template.postSubmit.rendered = function() {
$(function() {
var editor;
editor = new Simditor({
textarea: $("#input-content"),
placeholder: "Just write",
pasteImage: true,
toolbar: ["title", "bold", "italic", "underline"],
upload: {
url: "/upload"
}
});
});
};

post_submit.js:

<template name="postSubmit">
<form class="form" role="form">
<div class="form-group">
<textarea name="content" class="form-control" id="input-content" rows="3">{{content}}</textarea>
</div>
<button type="submit" class="btn btn-default submit">Submit</button>
</form>
</template>

post_page.js:

  <div class="mainbar col-md-12">
{{> postSubmit}}
</div>
</template>

编辑

this.route("postPage", {
path: "/posts/:_id",
data: function() {
return Posts.findOne(this.params._id);
}
});

它曾经工作得很好,但是在将 Meteor 更新到 0.8.0 后,内容突然从 contenteditable div(由 Simditor 生成)和 textarea(与前一个内容相同)中消失:

enter image description here

可能是什么问题?我认为这与新的 rendered 方法的工作方式有关。

最佳答案

这可能是因为您在子模板内使用 {{content}} 。从 0.8.0 开始,您无法再访问父模板的助手。但是,您可以访问父模板的数据。

这可能不起作用,但这可能是您遇到的问题。鉴于您提供的信息很难判断,并且不容易重现。

实现此功能的一种方法是扩展数据上下文以包含内容,或者手动发送它。

HTML

<template name="parentTemplate">

{{#with contentData}}
{{> postSubmit}}
{{/with}}
</template>

JS

Template.parentTemplate.helpers({

//Not sure about this part
contentData: function() {
return {
content: Template.parentTemplate.content()
}
}
});

关于javascript - Meteor更新到0.8.0后文本编辑器不显示内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22890639/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com