【问题标题】:Meteor template not updating using click event流星模板不使用点击事件更新
【发布时间】:2013-02-07 03:34:44
【问题描述】:

我正在尝试使用流星会话制作一个反应式菜单(以保持用户的视图).. 但它不起作用, Session.get('currentView') 被更改(chrome 控制台中的 teste),但页面不再呈现。

.html

<div class="col-1-1 menu" style="height: 42px;">
    <ul>
        <li><a class="dashButton" href="#"># Dashboard</a></li>
        <li><a class="myJobsButton"href="#">Jobs</a></li>
        <li><a class="helpPageButton"href="#">Help</a></li>
    </ul>
    <br style="clear:left"/>
</div>
{{#if currentViewIs "dashboard"}}
    {{> dashboard}}
{{else}}
    {{#if currentViewIs "myJobs"}}
        {{> myJobs}}
    {{else}}
        {{#if currentViewIs "helpPage"}}
            {{> helpPage}}
        {{else}}
            {{> dashboard}}
        {{/if}}
    {{/if}}
{{/if}}

client.js

Template.userPage.currentViewIs = function (view) {
    if( Session.get('currentView') == view)
        return true;
    return false;
};

Template.userPage.events({
    'click .dashButton': function (evt) {
        Session.set('currentView', 'dashboard');
  },
    'click .myJobsButton': function (evt) {
        Session.set('currentView', 'myJobs');
  },  
    'click .helpPageButton': function (evt) {
        Session.set('currentView', 'helpPage');
  }
});

【问题讨论】:

    标签: javascript node.js meteor handlebars.js reactiveui


    【解决方案1】:

    现在工作正常: - 用于 windows (win.meteor.com) 的流星中的一些奇怪错误,在停止服务器并刷新 chrome 后,它按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 2015-05-07
      • 1970-01-01
      • 2016-09-18
      • 2016-04-04
      相关资源
      最近更新 更多