Reputation: 73
here is my issue: I have a very basic main layout where you would click an item from a list of items and see the content of that clicked item displayed on a diffrent section of the page. I know there a some example of that that I could copy but since I am learning Meteor, I wanted to complete it myself.
here is the temmplate.js to get the session and return the content:
Template.lelementItem.events({
'click .clic': function(){
Session.set("clickedItem", this.ladescription);
}
});
Template.lelementItem.afficheDescription = function() {
return Session.get("clickedItem");
};
Here is the template.html
<template name="afficheDescription">
{{clickedItem}}
</template>
If I output the content in an alert like this it shows the content but I cannot output the content in the right place using template:
Template.lelementItem.events({
'click .clic': function(){
alert(this.ladescription);
}
});
Thanks for your help in advance..
Upvotes: 0
Views: 59
Reputation: 4101
Replace
Template.lelementItem.afficheDescription = function() {
return Session.get("clickedItem");
};
with
Template.afficheDescription.clickedItem = function() {
return Session.get("clickedItem");
};
In the first case, you're adding a helper afficheDescription
to the template lelementItem
. You want to add a helper clickedItem
to the template afficheDescription
.
Upvotes: 1