Meteor template not updating using click event
Asked Answered
K

1

2

I'm trying to make a reactive menu using meteor session (to persist the view the user was).. but it is not working, the Session.get('currentView') get changed (teste in chrome console), but the page don't render again.

.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');
  }
});
Kermie answered 21/2, 2013 at 17:25 Comment(0)
K
2

It is working fine now: - Some weird bug in meteor for windows (win.meteor.com), after stop server and refresh chrome it worked as supposed.

Kermie answered 21/2, 2013 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.