当数据改变时,模板的流星助手不会触发

Meteor helper of template not firing when data changes?

本文关键字:流星 改变 数据      更新时间:2023-09-26

我的客户端有以下内容:

Template.cellular.helpers({
    getCells: function() {
        console.log("getting cell list");
        things = cellItems.find({owner: Meteor.userId(), FileId: "someId"});
        console.log(things);
        return things;
    }
});
<template name="cellular">
    <div id='cellPane'>
        <div id='data'>
            {{#each getCells}}
                <div id="{{_id}}" >
                    <div class='celldesc' contenteditable="true" display="block">
                            {{description}}
                    </div>
                    <div class='cellval' contenteditable="true" display="block">
                            {{vals}}
                    </div>
                    <div class='cellformula' contenteditable="true" display="block">
                            {{formula}}
                    </div>
                </div>
            {{/each}}
        </div>
    </div>
</template>

当我插入以下内容时,它似乎没有触发显示控制台语句的helper,但我看到模板的闪烁被更新,然后被删除。发生了什么?我怎样才能改正呢?

{owner: Meteor.userId(), FileId: "someId", description: "something", vals: "0", formula: "something else"}

您正在添加FileId: "someId"的文档,但您的助手正在 dynaFileId: "someId" 上执行find(),因此您刚刚插入的文档不包括在光标中。