0
我想使用barbahams(babrahams:editable-text-wysiwyg-bootstrap-3)的可編輯文本包來編輯MongoDB中的另一個數組內的數組的內容,雖然外部每個似乎都工作正常以及內部(當我把它從外面的一個手動設置第一個$爲0,當我把任何editableText內部每個它根本無法工作。流星編輯文字不工作在級聯每個
我的模式是這樣的:
Params = new Mongo.Collection("params");
Params.attachSchema(new SimpleSchema({
title: {
type:String,
label: "title",
},
data: {
type: Array,
optional: true
},
'data.$': {
type: Object
},
'data.$.name': {
type: String
},
'data.$.values': {
type: Array
},
'data.$.values.$': {
type: String
},
}));
我的模板是這樣的:
<template name="param_edit_form">
{{#with param}}
{{#each data}}
{{#let [email protected]}}
{{> editableText context=.. collection='params' field=(get_name @index)}}: <!-- this one works -->
{{#each values data_index}}
<span style="color:#f00;">
{{this}} <!-- this one works, it displays the text I want, it's just that it is noe editable -->
{{> editableText context=.. collection='params' field=(get_value data_index @index)}}, <!-- this one doesn't work, nor any other editable text -->
</span>
{{/each}}
{{> editableText context=.. collection='params' field=(get_value data_index 0)}}, <!-- this one works -->
{{/let}}
{{/each}}
{{/with}}
</template>
..和我的助手是這些:
Template.param_edit_form.helpers({
param: function(){
return Params.findOne({_id:Session.get("paramid")});
},
// find all visible data
data: function(){
if (this.data) {
return this.data;
}
},
// find all visible values
values: function()
if (this.values) {
return this.values;
}
},
get_name: function(dataIndex){
return 'data.' + dataIndex + '.name';
},
get_value: function(dataIndex, index){
return 'data.'+dataIndex+'.values.'+index;
},
});
PS:我相信我能解決它與一個可編輯DIV和事件監聽器等,它只是我想找出爲什麼不以這種方式工作。