Skip to content

Instantly share code, notes, and snippets.

@dohomi
Last active August 29, 2015 14:01
Show Gist options
  • Save dohomi/d3f23cd784b066cadef7 to your computer and use it in GitHub Desktop.
Save dohomi/d3f23cd784b066cadef7 to your computer and use it in GitHub Desktop.
Simple filter over collection
Template.exerciseList.events({
"keyup .js-exercise-text-search": function (ev, templ) {
Session.set("ExerciseListFilter", {"name": {$regex: ev.currentTarget.value, $options: 'i'}});
}
});
Template.exerciseList.helpers({
exercises: function () {
Session.set("ExerciseListFilter", {});
return TP.Collections.Exercises.find(Session.get("ExerciseListFilter"));
}
});
<template name="exerciseList">
<form name="exercise-list-search" class="js-exercise-list-search" role="form">
<input type="text" class="js-exercise-text-search form-control" />
</form>
{{#each exercises}}
{{> exerciseListItem}}
{{/each}}
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment