Meteor editabletext在级联每个时都不起作用

时间:2017-03-15 01:11:12

标签: meteor meteor-blaze

我正在尝试使用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 data_index=@index}}
                {{> 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和事件监听器等解决它,我只想知道它为什么不以这种方式工作。

1 个答案:

答案 0 :(得分:0)

我在包的GitHub回购中发布了相同的问题,它已被回答,所以我发布了链接:

https://github.com/JackAdams/meteor-editable-text/issues/79