Making a template helper reactive in Meteor

后端 未结 5 778
刺人心
刺人心 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:27

    You could use a local Meteor.Collection cursor as a reactive data source:

    var NewChatters = new Meteor.Collection("null");
    

    Template:

    
    

    Event:

    Template.contactsLayout.events({
      'click #contactItem': function (e) {
        NewChatters.insert({username: this.username});
      }
    });
    

    Helper:

    Template.newChatDetails.helpers({
      newChatters: function() { return NewChatters.find(); }
    });
    

提交回复
热议问题