Making a template helper reactive in Meteor

后端 未结 5 784
刺人心
刺人心 2021-02-08 02:22

I am building a chat application and on my \"new chats\" page I have a list of contacts, which you can select one by one by tapping them (upon which I apply a CSS selected class

5条回答
  •  长发绾君心
    2021-02-08 02:41

    for people who is looking for a workaround for this in the year 2015+ (since the post is of 2014).

    I'm implementing a posts wizard pw_module where I need to update data reactively depending on the route parameters:

    Router.route('/new-post/:pw_module', function(){
        var pwModule = this.params.pw_module;
        this.render('post_new', {
            data: function(){
                switch (true) {
                    case (pwModule == 'basic-info'):
                        return {
                            title: 'Basic info'
                        };
                        break;
                    case (pwModule == 'itinerary'):
                        return {
                            title: 'Itinerary'
                        };
                        break;
                    default:
                }
            }
        });
    }, {
        name: 'post.new'
    });
    

    Later in the template just do a:

    {{title}}

    Changing routes

    The navigation that updates the URL looks like this:

    
    

    Hope it still helps someone.

提交回复
热议问题