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

  • Home
  • SEARCH
  • 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 8095333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:05:31+00:00 2026-06-05T21:05:31+00:00

I just started with backbone.js and is currently making a page which has a

  • 0

I just started with backbone.js and is currently making a page which has a div #listing_filter containing text input elements and a table showing some listings fetched from a RESTful backend (PHP/Codeigniter). The values in the text input will act as filters to narrow down the results retrieved by the server.

Problem: Whenever the value in any of the text boxes changes, I want the browser to GET another set of results based on the filter values. Below is my attempt, where the updateFilter function does not fire even though the text input value was changed. Any ideas what went wrong?

Another question will be whether I should put the contents of #listing_filter into a template, or just hardcode it into the main body HTML? Thanks!

JS Code

window.ListingFilterView = Backbone.View.extend({
    initialize: function() {
        _.bindAll(this, 'updateFilter');
    },

    events: {
        'change input' : 'updateFilter'
    },

    updateFilter: function() {
        console.log('hey');
    }

});

// Router

var AppRouter = Backbone.Router.extend({
    routes: {
        '': 'listings',
    },

    listings: function() {
       //... some other code here
        this.listingFilterView = new ListingFilterView();
    }
});

HTML Code

<div id="listing_filter">
    Price: <input type="text" id="listing_filter_price" />
    Beds: <input type="text" id="listing_filter_bedroom" />
    Baths: <input type="text" id="listing_filter_bathroom" />
</div>
  • 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-05T21:05:34+00:00Added an answer on June 5, 2026 at 9:05 pm

    A Backbone view will only respond to events on the view’s el or on elements that are inside its el. By default, the view’s el is just an empty <div> and you’re not telling the view to use anything else.

    You can tell the view which el to use (http://jsfiddle.net/ambiguous/5yXcU/1/):

    new ListingFilterView({ el: $('#listing_filter') })
    // Or like this:
    new ListingFilterView({ el: '#listing_filter' })
    

    or you can let the view attach itself to that element using setElement (http://jsfiddle.net/ambiguous/APEfa/1/):

    initialize: function() {
        this.setElement($('#listing_filter'));
        // or setElement('#listing_filter')
    }
    

    or set the el when you define the view (http://jsfiddle.net/ambiguous/nyTZU/):

    window.ListingFilterView = Backbone.View.extend({
        el: '#listing_filter',
        //...
    });
    

    Once that’s out of the way, you’ll need to understand that an <input> won’t trigger a change event until it loses focus so you’ll have to wait for the user to tab-out of the input or switch to listening for keypress events and using a timer to detect when they’ve stopped typing.

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

Sidebar

Related Questions

Just started with backbone.js and javascript. On my collection, I can listen for 'reset'
I just started with backbone.js, and one thing that I noticed is that sometimes
I just started to delve into backbone.js and I am not sure what is
We've just started using Backbone and I'm trying to get a handle on a
I just started learning Backbone.js, and have been working on (what else) a simple
Just getting started with Backbone.js. Simply including Backbone (either dev/production versions) causes the error:
I am just getting started with Backbone.js , but it looks really interesting... Right
I've just started using Backbone (and Underscore) JS. We are doing a big iPad
I have just started with backbone.js. And I'm having a problem in fetching the
I have just started exploring Backbone.js. Upon submission of a form I would like

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.