【问题标题】:Meteor editabletext do not work in cascading each流星可编辑文本在级联每个时不起作用
【发布时间】:2017-03-18 12:56:18
【问题描述】:

我正在尝试使用 barbahams 的可编辑文本包 (babrahams:editable-text-wysiwyg-bootstrap-3) 来编辑 mongodb 中另一个数组内的数组内容,尽管外部每个似乎也可以正常工作作为内部(当我将它从外部取出并手动将第一个 $ 设置为 0 时,当我将任何可编辑文本放入内部每个时,它根本不起作用。

我的架构是这样的:

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 和事件侦听器等解决它,只是我想找出为什么它不能这样工作。

【问题讨论】:

    标签: meteor meteor-blaze


    【解决方案1】:

    我在包的 GitHub 存储库中发布了相同的问题,它已经得到了回答,所以我发布了指向该问题的链接:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多