Помогите мне с фильтрацией

Тема в разделе "Другие языки", создана пользователем Internet_Contraband, 6 ноя 2011.

Модераторы: Цукер
  1. Internet_Contraband

    Internet_Contraband

    Регистр.:
    19 окт 2007
    Сообщения:
    230
    Симпатии:
    58
    Существует библиотека: http://listjs.com/examples/standard.html
    пытаюсь добавить еще одну категорию фильтрации:
    кнопка:
    Код:
     <ul class="filter">
      <li class="btn" id="filter-none">Show all</li>
      <li class="btn" id="filter-games">Only show games</li>
      <li class="btn" id="filter-beverages">Only show beverages</li>
      <li class="btn" id="filter-new">Only show new</li>
     </ul>
    
    код для работы:
    Код:
        <!-- Start of List.js stuff -->
        <script src="../../src/list.js"></script>
        <script type="text/javascript">
            /* 
            * LOVELY THINGS
            */
            var templates = {
        	    valueNames: [ 'name', 'description', 'category' ]
            };
            var featureList = new List('lovely-things-list', templates);
            $('#filter-games').click(function() {
                featureList.filter(function(values) {
                    if (values.category == "Game") {
                        return true;
                    } else {
                        return false;
                    }
                });
                return false;
            });
            $('#filter-beverages').click(function() {
                featureList.filter(function(values) {
                    if (values.category == "Beverage") {
                        return true;
                    } else {
                        return false;
                    }
                });
                return false;
            });
            $('#filter-new').click(function() {
                featureList.filter(function(values) {
                    if (values.category == "new") {
                        return true;
                    } else {
                        return false;
                    }
                });
                return false;
            });
            $('#filter-none').click(function() {
                featureList.filter(function(values) {
                    return true;
                });
                return false;
            });
        </script>
        <!-- End of List.js stuff -->
    
    добавление нового элемента
    Код:
                           <ul class="list">
                                <li>
                                    <img src="images/monkeyisland.jpg" class="thumb" />
                                    <h4><span class="name">Monkey Island 2: LeChuck's Revenge</span> <span class="category">Game</span></h4></h4>
                                    <p class="description">Monkey Island 2: LeChuck's Revenge is an adventure game developed and published by LucasArts in 1991. It was the second game of the Monkey Island series, following The Secret...</p>
                                </li>
                                <li>
                                    <img src="images/coffee.jpg" class="thumb" />
                                    <h4><span class="name">Coffee</span> <span class="category">Beverage</span></h4></h4>
                                    <p class="description">Coffee is a brewed beverage with a dark, slightly acidic flavor prepared from the roasted seeds of the coffee plant, colloquially called coffee beans.</p>
                                </li>
                                <li>
                                    <img src="images/fullthrottle.jpg" class="thumb" />
                                    <h4><span class="name">Full Throttle</span> <span class="category">Game</span></h4></h4>
                                    <p class="description">Full Throttle is a computer adventure game developed and published by LucasArts. It was designed by Tim Schafer, who would later go on to design the critically acclaimed titles Grim Fandango, Psychonauts and Brütal Legend.</p>
                                </li>
                                <li>
                                    <img src="images/brooklyn.jpg" class="thumb" />
                                    <h4><span class="name">Brooklyn Lager</span> <span class="category">Beverage</span></h4>
                                    <p class="description">Brooklyn Brewery was started in 1987 by former Associated Press correspondent Steve Hindy and former Chemical Bank lending officer Tom Potter.</p>
                                </li>
                                <li>
                                    <img src="images/brooklyn.jpg" class="thumb" />
                                    <h4><span class="name">New</span> <span class="category">new</span></h4>
                                    <p class="description">Brooklyn Brewery was started in 1987 by former Associated Press correspondent Steve Hindy and former Chemical Bank lending officer Tom Potter.</p>
                                </li>
                            </ul>
    
    и фильтрации не работает корректно... Второй фильтр работает правильно, третья кнопка перестает работать после первого использования. и т.д.
    можете помочь? спасибо