Javascript 文本编辑器doen';t将Meteor更新为0.8.0后显示内容
我最近融入: post\u submit.html:Javascript 文本编辑器doen';t将Meteor更新为0.8.0后显示内容,javascript,meteor,Javascript,Meteor,我最近融入: post\u submit.html: Template.postSubmit.rendered = function() { $(function() { var editor; editor = new Simditor({ textarea: $("#input-content"), placeholder: "Just write", pasteImage: true, toolbar: ["title",
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"
}
});
});
};
<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>
<div class="mainbar col-md-12">
{{> postSubmit}}
</div>
</template>
post_submit.js:
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"
}
});
});
};
<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>
<div class="mainbar col-md-12">
{{> postSubmit}}
</div>
</template>
它曾经工作得很好,但在将Meteor更新为0.8.0后,contenteditable div(由Simditor生成)和textarea(其内容与前一个相同)中的内容突然消失:
有什么问题吗?我认为这与新的
呈现
方法的工作方式有关。这可能是因为您正在子模板中使用{{content}
。从0.8.0开始,您不能再访问父模板的帮助程序。但是,您可以访问父模板的数据
这可能不起作用,但这可能是您遇到的问题。考虑到你提供的信息,很难说出来,因为它不容易复制
实现此功能的一种方法是扩展数据上下文以包含内容
,或者手动发送
HTML
这肯定与新的渲染引擎有关。使用jquery插件的方式可能会有所不同。请务必阅读并@imslavko谢谢,但我的
呈现的
和jQuery
代码似乎与该页面中显示的代码相同?我对代码进行了折射,以便表单是后期模板的一部分,而不是子模板。同样的问题。我认为新的只渲染一次模型由于某种原因导致内容从textarea/contenteditable div中消失。如果我把内容放在其他地方,它会显示出来。我想我对这个问题有了更多的理解。请尝试在呈现页面之前等待订阅完成,或者在数据更改时使用Deps.autorun()重新运行模板.postSubmit.rendered
(或新的postPage)以重新初始化SimEditor。所以这就像以前一样谢谢你能给我一个在Template.postSubmit.rendered
上使用Deps.autorun()
的例子吗?我试着把它放在Template.postSubmit.rendered=function(){
下面,但没有用。不是那样,你必须调用.rendered function()中的代码我可以提供更多的帮助,但我需要你在查询的反应部分发布一些代码/如何将数据从js获取到模板中,因为Deps.autorun
需要识别何时重新运行。