【问题标题】:Meteor changing another template reactively流星反应性地改变另一个模板
【发布时间】:2015-03-24 01:11:28
【问题描述】:

我在启动时加载了几个模板, 加载页面后,用户可以选择几个项目来定义另一个模板的内容。这就是我卡住的地方。

如何在调用我的方法并将结果存储在我的会话中之后,我可以将它发送到另一个模板。

我看过Deps.Dependency 确实很简单。

【问题讨论】:

    标签: meteor meteor-helper


    【解决方案1】:

    假设在第一个模板上,您有一个要保存结果的选择元素:

    <template name="foodSelect"> <select id="favorite-food"> <option> Taco </option> <option> Burrito </option> </select> </template>

    在该模板的帮助器中,您可以检查该类型输入的事件:

    Template.foodSelect.events({
        "change #favorite-food" : function(event, template) {
            var input = $(event.target).val();
            Session.set('favorite_food', input);
        }
    });
    

    在您的其他模板中,您可以使用Session.get('favorite_food') 访问它并相应地更改内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-29
      • 2013-11-14
      • 1970-01-01
      • 2017-09-15
      相关资源
      最近更新 更多