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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:29:40+00:00 2026-06-11T01:29:40+00:00

I develop a jquery & backbone.js web app. One component has an html table

  • 0

I develop a jquery & backbone.js web app.
One component has an html table and behind this table is a backbone.js collection.
Any change in this collection should lead to an update of the html table, so I write

this.collection.bind("reset add remove", this.renderRows, this);    

So I update the html table, when the whole collection gets new, when a new model gets added and when a model gets removed.

There’s also a detail view component that gets called when the user hovers and clicks over a certain row of the html table. At the beginning of this component I get the right model out of the collection

changeModel = this.collection.get(id);

After the user has changed some attributes, I do

changeModel.set(attrs); 

and return to the html table. The model in the collection has the correct changed values.

But the html table is not updated as none of the 3 events (reset, add, remove) was triggered.

So I added “replace” to the collection binding

this.collection.bind("replace reset add remove", this.renderRows, this);

and before returning from the detail view I called

this.collection.trigger("replace");

My solution works, but my question is:

Is there any “native” backbone.js solution that is already there and that I have missed and where I do not have to trigger something by myself?

  • 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-11T01:29:42+00:00Added an answer on June 11, 2026 at 1:29 am

    The change events from models bubble up to the collection. (Collection’s _onModelEvent -function in the annotated source. The method just basically takes all events from models and triggers them on the collection.

    This leads to

    1. Model attribute is set
    2. Model triggers change
    3. Collection catches change
    4. Collection triggers change

    So

    this.collection.bind("replace reset add remove", this.renderRows, this); 
    

    has to be replaced with this

    this.collection.bind("change reset add remove", this.renderRows, this);
    

    P.S.

    My personal opinion is that you shouldn’t redraw the whole table if just one model is changed. Instead make each table row a view in itself that has the corresponding model as its model and then react to attribute changes there. There is no point in redrawing 500 table cells if you’re targeting just one.

    UPDATE

    And nowadays you should use the on -method for binding to events.

    collection.on("change reset add remove", this.renderRows, this);
    

    If you’re using BB 1.0, and this event is being listened to within a View, I suggest moving to use the new listenTo to bind into events, which also allows for easy unbinding when calling view.remove(). In that case you should do:

    // assuming this is the view
    this.listenTo(collection, "change reset add remove", this.renderRows);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop a web app using HTML5, CSS3, JQuery Mobile (so that
I am trying to develop an iPhone app using PhoneGap and jQuery Mobile. This
I'm using jQuery to develop in web environment. I want to know why $(#a#trigger).trigger('mouseenter');
im develop app with phonegap and create index.html -> html5 and of course use
trying to develop web form using jquery. all i need is to have several
How to develop confirmation dialog with yes no button using jquery or any other
I'm trying to develop android web apps using html 5.I'm using dreamviewer 5 with
I'm using jQuery Mobile (jQM) and Knockout.js (ko) to develop an application. In this
I want to develop a test project for inline editing using jQuery. In this
I have a client who has requested I develop a simple web designer (ala

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.