为了用contenteditable区域和Meteor修复文本复制错误,我做了以下工作:
document_page.js:
Template.documentPage.helpers({
contenteditable: function() {
return '<div class="content" contenteditable="true">' + this.content + '</div>'
},document_page.html:
<div class="editor">
<input class="title" type="text" value="{{title}}">
{{{contenteditable}}}
</div>现在的问题是jQuery不再适用于{{contenteditable}}生成的HTML。
示例:
Template.documentPage.rendered = function() {
$('.content').addClass('test') // <--this does nothing我怎么才能解决这个问题?
发布于 2015-01-28 04:20:10
嗨,亚历克斯,代码实际上是有效的,只要删除+this.content‘+to +’按钮就可以开始编辑div‘+’,因为您创建的对象没有内容。
我们用这个代替this.content。
var finde = Documents.findOne({_id:this._id})
return '<div class="content" contenteditable="true">' +finde.content + '</div>'并将使用该助手的模板放置在路由上的waitOn中。
waitOn:function(){
if(this.ready()){
//render the template
}else{
//render the loading template
}
}如果你console.log(this)。
你会得到object {}。
https://stackoverflow.com/questions/28183652
复制相似问题