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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:29:14+00:00 2026-05-24T06:29:14+00:00

I am beginning to use Backbone and am trying to transition my Rails backend’s

  • 0

I am beginning to use Backbone and am trying to transition my Rails backend’s html templates to javascript templates.

One thing I thought using backbone would be more advantageous is its concept of Models and Collections.
So say, I have 100 records and am paginating these records to 10 per page, normally, without quite a bit of javascript work, one can hardly expect a cached, ajax, one-page pagination experience. meaning, say, I landed on page one and now click page two, page two requests the next 10 records ajax’ly, and if I then click page one, I won’t be making any more request to the server because it was there.

I haven’t had any code written up but can anyone tell me how I can append the ajax requested newly arrived data to the existing collection for pagination?

For instance, remember Backbone’s documentation say that your first load of the page should really contain bootstrapped data instead of making a second trip to fetch them. So

var projects_data = <%= @projects.to_json.html_safe %>;
var projects = new Cafe.Collections.ProjectsCollection();
var projects.reset(projects_data);

Now my projects variable contains, say, the first 10 records, and I someone retreive another round of 10, say, I save these newly arrived 10 in the variable

var projects_data_new = ...

Can I append them to the existing “projects” collection?

Or is this not the design pattern encouraged in Backbone in the case of pagination?

  • 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-05-24T06:29:15+00:00Added an answer on May 24, 2026 at 6:29 am

    In backbone 0.5 and up, when you call fetch(), it is possible to specify that you wish to add rather than replace the dataset present on the client: fetch({add: true}). This will append new objects to the existing projects collection. You will still have to handle pagination presentation issues on your end.

    The collection also only gets the JSON objects to add/fetch after they have been run through Backbone.Collection.parse(), which you can override to do things like “along with the projects, give me a count of all objects on the server, and return only the projects to the add/fetch.” You can then use this metadata to correctly show how many pages the user can page through. If you want to be really clever, you can use the collection as a sparse array (my experience is that this is fine for collections of less than 10,000 items on a standard desktop or laptop, but not a tablet), and let the user flip through the pages arbitrarily, fetching the filler as needed.

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

Sidebar

Related Questions

I'm beginning python and I'm trying to use a two-dimensional list, that I initially
We are beginning to use VS2012 for our solution. One of the projects is
I'm just beginning to use Python 2.7 and am trying to build a simple
I'm trying to work through http://railscasts.com/episodes/155-beginning-with-cucumber which basically teaches how to use Cucumber within
Beginning to use perl RegExp.I am using the following RegExp to catch unwanted blank
I am following the Mhartl Ruby on Rails tutorial and beginning to use Rspec.
I am trying to use corelocation at the very beginning of my app, to
I am beginning to use SLF4J for logging and the first thing that strikes
Since beginning to use VB.NET some years ago I have become slowly familiar with
I'm beginning to use the swtbot to test my reccent eclipse rcp projekt. A

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.