I have a problem with the filter and everyone. I want to create a filter that changes the data according to this filter.
<select id="filter">
<option value="all">all</option>
<option value="one">one</option>
<option value="two">two</option>
</select>
{{#each datas}}
<span class="badge">{{Name}}</span>
{{/each}}
Template.mytemp.created = function(){
Session.set("activefilter", "all");
};
Template.mytemp.datas = function(){
var ac = Session.get("activefilter");
var result = new Array();
if(ac != undefined){
var data = RawData.find({filter:ac}).fetch();
for(var ii = 0; ii < data.length;ii++){
var nData = NextData.findOne({_id : data[ii].Next_ID});
result[ii] = {
Name : nData.Name
};
}
return result;
}
};
i create an event handler as follows:
Template.mytemp.events({
'change #filter':function(){
Session.set("activefilter",$('#filter').val());
}
});
Each time I change the filter, nothing happens, the data for each does not change. please help me how to update data when filter changes?
source
share