Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:08:15+00:00 2026-06-13T19:08:15+00:00

I have a search form: <form class=navbar-search pull-right data-bind=submit: findBook> <input type=text class=search-query placeholder=Search

  • 0

I have a search form:

<form class="navbar-search pull-right" data-bind="submit: findBook">
    <input type="text" class="search-query" placeholder="Search" id="search-input"> 
    <i class="icon-search"></i>
    <input type="submit" value="Submit">
</form>

I’m listing the books here:

<ul id="container" class="list" data-bind="foreach: books">
    <li>
    <div>
    <table>
    <tr>
    <td class="center">
    <a data-bind="attr:{href: url}">            
       <img width="150" class="img-polaroid shadow" data-bind="attr:{src: image}">
    </a>
    </td>
    </tr>   
    <tr>
    <td class="center">
        <h6 data-bind="text: name"></h6>
    </td>
    </tr>
    </table>
    </div>
    </li>
</ul>

And a findBook method in my ViewModel:

    self.books = ko.computed(function() {
        return ko.utils.arrayFilter(library, function(book) { 
          return self.selectedCategory() == null ||
              book.category === self.selectedCategory(); 
          })
    });
    self.findBook = function() {
        self.books = ko.computed(function() {
            return ko.utils.arrayFilter(library, function(book) {
                return book.name.match(new RegExp($('#search-input').val(), 'i'));   
            });
        });
    };       
}

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:08:17+00:00Added an answer on June 13, 2026 at 7:08 pm

    Your findBook function is attempting to replace the books computed observable with a different one. Your view was already bound to the previous one so you’re not going to see any changes there.

    You need to change your books computed observable to depend on some filter. If the filter is not set, include the item. If the filter is set, exclude it.

    self.selectedCategory = ko.observable('');
    self.nameFilter = ko.observable('');
    
    self.books = ko.computed(function () {
        var selectedCategory = self.selectedCategory(),
            nameFilter = self.nameFilter(),
            selectedFilter = filter && new RegExp(filter, 'i');
        return ko.utils.arrayFilter(library, function (book) {
            var validCategory = !selectedCategory || book.category === selectedCategory,
                validFilter = !selectedFilter || book.name.match(selectedFilter);
            return validCategory && validFilter;
        });
    });
    
    self.searchInput = ko.observable();
    self.findBook = function (element) {
        self.nameFilter(self.searchInput());
    };
    

    Demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form: <input name=q value= class=qa-search-field> <input type=submit value=Search class=qa-search-button> I
I have the following form: <form class=navbar-search pull-left action=http://www.example.com/movie/<id> id=get-movie-form> <input type=text class=search-query placeholder=Input
I have a class project where I am using a VB.Net form to search
I have a search form. I would like when someone type the term, first
I have a search form with inputs and selects, and when any input/select is
I have a form that has a choice list: <select name=cellSerpro id=idcellserpro class=field text
I have a search form on which I have the following INPUT field <input
I have this form: <%= form_tag posts_path, :method => :get, :class => search_nav do
I have a search form where user can search for products within their specified
I have a search form on my site that submits the url in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.