From 2eb37a82ca620608f4463e9c7b8d49f096b284c8 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 20 Feb 2012 19:52:06 +0530 Subject: [PATCH] list filter --- chaloBEST/static/js/editstops.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/chaloBEST/static/js/editstops.js b/chaloBEST/static/js/editstops.js index b555383..ca885ea 100644 --- a/chaloBEST/static/js/editstops.js +++ b/chaloBEST/static/js/editstops.js @@ -19,8 +19,8 @@ $(function() { $.each(items, function(i,v) { var $li = $('
') .addClass("listItem") - .text(v) .appendTo($list); + var $txt = $('').addClass("listItemText").text(v).appendTo($li); }); }); } @@ -44,7 +44,7 @@ $(function() { $target.find(".stopsList").toggle(); return; } - var url = API_BASE + name + "/" + $target.text(); + var url = API_BASE + name + "/" + $target.find(".listItemText").text(); $target.data("loading", true); var $loading = $('').addClass("loadingSpan").text("Loading...").appendTo($target); $.getJSON(url, {}, function(obj) { @@ -58,6 +58,21 @@ $(function() { }); }); + $('.listSearch').keydown(function(e) { + var val = $(this).val(); + var name = $(this).attr("id").replace("Search", ""); + var $list = $('#' + name + "List"); + $list.find(".listItem").each(function() { + var $that = $(this); + var txt = $that.find(".listItemText").text(); + if (txt.indexOf(val) == -1) { + $that.hide(); + } else { + $that.show(); + } + }); + }); + }); function getStopsList(stops) {