vendredi 8 mai 2015

Transfer the context of `this.data` to other templates in Blaze/Meteor?

I have a route gathering some data.

Router.map(function () {
  this.route('Players.guild', {
    path: '/players/guild/:guildId',
    template: 'GuildPlayerList',
    waitOn: function () {
      return Meteor.subscribe('guild_players', this.params.guildId);
    },
    data: function () {
      return Players.find({ guildId: this.params.guildId });
    }
  });
});

Then, I have a simple template

template(name="GuildPlayerList")
  +ionList
    +each this
      +ionItem avatar=true ion-data-modal="_playerModalView"
        img(src="{{ imageId store='PlayerThumbnails' }}" alt="{{ name }}")
        h2 {{ name }}

template(name="_playerModalView")
  // I want the current player in the +each to push its context of this here
  +ionModal title="{{ name }}"

The problem, however, is it seems that the context of this changes when I load the modal. In other cases, I have used _.bind to push the context of this, but how can this be done with blaze templates?

Aucun commentaire:

Enregistrer un commentaire