Reputation: 690
I want to pass data through template but i am getting undefined i have two variables inside the customer template and when user click i want to pass these two var to the next template customerchathistory like
Template.customer.events({
async 'click .list-chat'(event,template) {
const Rid = event.currentTarget.id;
const Rtoken = event.currentTarget.token;
}
})
Here i am passing those var like this in customer.html
{{>cutomerChatHistory clickRid= Rid clickRtoken = Rtoken }}
Now when i am fetching these two var inside the customerChatHistory.js i am getting undefined
Template.customerChatHistory.onCreated(function() {
const currentData = Template.currentData();
console.log(currentData.clickRid , currentData.clickRtoken) //giving undefined here
})
Upvotes: 0
Views: 421
Reputation: 777
You need to define Rid
and Rtoken
variables in helpers so that they become available in Blaze html template :
Template.customer.events({
async 'click .list-chat'(event,template) {
template.Rid.set(event.currentTarget.id);
template.Rtoken.set(event.currentTarget.token);
}
})
Template.customer.helpers({
Rid: function(){
return Template.instance().Rid.get();
}
Rtoken: function(){
return Template.instance().Rtoken.get();
}
})
Template.customer.onCreated({
this.Rid = new ReactiveVar(null)
this.Rtoken = new ReactiveVar(null)
})
Upvotes: 0