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 8400907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:40:11+00:00 2026-06-09T21:40:11+00:00

I have this backbone script, which has a single view and a model acting

  • 0

I have this backbone script, which has a single view and a model acting as a controller, and a collection where data is being fetched from the server url: '/search/:term' .

    var Items = Backbone.Collection.extend({
          initialize: function(terms){
            this.fetch();
        }
          url: 'search/:term'
    });

   var Controller = Backbone.Model.extend({
       defaults:{
        term: ""
     },
      initialize: function(opts){

        this.on('change:term', function(term){
            console.log(this.get("term"));
          // every time term changes i want to refresh the collection with the new data
          // so it will fetch data from url:'search/ + term'
        });

could someone help me with this thank you.
}
});

  • 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-09T21:40:13+00:00Added an answer on June 9, 2026 at 9:40 pm

    In a backbone context a View acts as a Controller (read controller form mvc). Can you try to do something like this?

    YourView = Backbone.View.extend({
      events : { 
        'change #dom-id' : 'handleChange' //function to fire when you change the dom
      },
      initialize: function(){
        this.collection.bind("reset", updateView); //when collection is done, updateView fires
      }, 
      render: function(){
        //do your render logic here, use a template etc.. //initial rendering
      },
      handleChange : function(changeEvent){
        //get value from dom-element, tell the collection to 
        //fetch again with the new term
      },
      updateView : function(){
        //Code that fires when the collection is done fetching 
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view and collection like this: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events:
I have to code: window.TicketCollection = Backbone.Collection.extend({ model:Tickets, url:/index.php/tickets/viewJSON }); window.TicketsView = Backbone.View.extend({ tagName:'div',
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
If i have this model: var myParentModel = Backbone.Model.extend({ defaults:{ parent1: null, parent2: null}
I have simple user model: var user = Backbone.Model.extend({ initialize: function(){ this.bind(change:auth, function (){
let's say I have : var Book = Backbone.Model.extend(); var Collection = Backbone.Collection.extend({ model:
I have the following in test.html: <script> var Foo = Backbone.Model.extend({ initialize: function(options) {
I'm using Backbone.js have a segmented control-type UI element for each model's view. They
I have a router like this, as main entry point: window.AppRouter = Backbone.Router.extend({ routes:
I have this form, in which i need to populate a combo box with

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.