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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:13:47+00:00 2026-05-31T21:13:47+00:00

I’m building a filemanager using backbone.js. Its part of a CMS (content managament system)

  • 0

I’m building a filemanager using backbone.js. Its part of a CMS (content managament system) Im building, and is accessed via a lightbox/modal window. I need to show both files attached to a certain content type (like a post) and also all files in general.

At this point I have two separate collections, a libraryCollection (all files) and galleryCollection (a posts files). The first problem I’ve encountered with this method is: editing a file in the libraryCollection and binding a model change event to the view obviously doesnt affect the galleryCollection view.

Is there a better way to do this? Im thinking I will need pagination for the libraryCollection (as in REAL pagination with only xx number of results retrieved from the server) and this might complicate things. Unless loading potentially thousands of records into the collection is ok?

Update:

The quickest (possibly dirtiest) method was to use the built in Backbone.Events system. Sample code:

var aggregator = {};
_.extend(aggregator, Backbone.Events);

aggregator.on("fileUpdated", function(model){
    if(app.libraryCollection && app.galleryCollection){
        libraryModel = app.libraryCollection.get(model.get("id"));
        galleryModel = app.galleryCollection.get(model.get("id"));
        libraryModel.set(model.attributes);
        galleryModel.set(model.attributes);
    }   
});

Then the Editor view:

window.EditorView = Backbone.View.extend({

    saveModel: function(){
        self = this;
        form = $(this.el).find("form").serializeArray();
        _.each(form, function(field){
            self.model.set(field["name"], field["value"]);
        });
        self.model.save();
        aggregator.trigger("fileUpdated", this.model);
    }
});

This syncs the models across both collections, and because I bound the model change event with the render function (not shown) the view reflects the changes across both the library and gallery views.

  • 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-31T21:13:49+00:00Added an answer on May 31, 2026 at 9:13 pm

    One potential solution to your problem of communicating between separate Backbone.js components is to us an event aggregator. In the event aggregator pattern, components such as views will share a reference to an aggregator, which is an object that serves as a central communications hub for your application. Instead of a view subscribing to events on another view, both talk to the aggregator, which passes messages along to any component that subscribes for that type of message.

    For example, your libraryCollection might fire a fileAdded event on the aggregator, passing the new file object in the message. Your galleryCollection would subscribe to the fileAdded event on the aggregator, and it would take some action when it fires, such as refreshing itself from the server or adding the passed file object to itself.

    Here’s an excellent blog post that covers the event aggregator pattern.

    Loading thousands of records into a collection at once sounds like a recipe for trouble.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload

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.