Last active
December 11, 2015 01:38
-
-
Save shanemcd/4524573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Instruments2.Views.FilterQuestionSets extends Backbone.View | |
template: JST['folders/filter'] | |
id: "filter-question-sets" | |
className: "clearfix" | |
events: | |
"keyup input[type=text]": "filter" | |
render: -> | |
@$el.html(@template()) | |
filter: (e) -> | |
query = $(this.el).find("input").val() | |
if query == "" | |
$(".question-set-in-list").show() | |
#some ghetto caching | |
unless @question_sets | |
@question_sets = $(".question-set-in-list") | |
# Loop over the question sets and show / hide | |
@question_sets.each -> | |
name = $(this).find("a").html() | |
expression = new RegExp(query,"gi") | |
match = name.match(expression) | |
if match == null | |
$(this).hide() | |
else | |
$(this).show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment