I am having trouble accessing a subscription inside an event handler:
on the SERVER, I am publishing:
Meteor.publish('basicInfoPub',function() {
if (!this.userId) {
return this.ready();
}
return BasicInfo.find(
{ userId:this.userId },
{ fields: {firstName:1, lastName:1, middleName:1, someCodes:1}
});
});
On the CLIENT, am subscribing, and then trying to access the subscription data in an event handler.
Template.basicInfo.onCreated(function(){
basicInfoSub = this.subscribe('basicInfoPub');
});
//event handler
'click #populateFormButton': function(e,instance){
if(instance){
$('#firstName').val(instance.data.basicInfoSub.firstName);
$('#lastName').val(instance.data.lastName);
$('#middleName').val(instance.basicInfoSub.middleName);
}
}
In the event handler, none of the 3 options shown actually work (instance.data, instance.basicInfoSub, or instance.data.basicInfoSub). How do I access firstName, lastName etc inside the event handler?
Thanks!