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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:44:38+00:00 2026-06-11T17:44:38+00:00

Is it possible to create a view which lists a collection which is binded

  • 0

Is it possible to create a view which lists a collection which is binded to different models? Also can the sort function be used?

For example I have ‘sales’ and ‘accounts’ model and would like to make a view with all the names of the people working in those departments.

Thanks

  • 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-11T17:44:40+00:00Added an answer on June 11, 2026 at 5:44 pm

    Sure. What you usually do is end up using a combination of applying event listeners on the collection, creating small subviews which represent each model and binding the model event handlers through that.

    BigView = Backbone.View.extend({
        el: 'ul',  // This view is a <ul> and we'll be adding the model views
        initialize: function() {
            // This collection represents the collection you passed in
            // For our purpose lets say it was a SalesCollection
            this.collection.on('reset', this.addAllSales, this);
            this.collection.on('add', this.addSale, this);
        },
        addAllSales: function() {
            var that = this;
            this.collection.each(function(sale) {
                that.addSale(sale);
            });
        }
        addSale: function(model) {
            var view = new Subview({
                'model': model
            });
            this.$el.append(view.render().el);
        }
    });
    
    SaleView = Backbone.View.extend({
        initialize: function() {
            this.model.on('change', this.something, this);
        },
        render: function() {
            this.$el.html();  // Or whatever else you need to do to represent a sale as view
            return this;
        }
        something: function(model) {
            // Code for something
        }
    });
    

    So in this example, you basically have your main view that has a collection (e.g. sales). When the sales collection is reset, it fires up the addAllSales(). Each time an sale is added to the collection we add a subview that represents the specific model (sale model). In this subview, we take care of binding events to the model changes which then do something.

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

Sidebar

Related Questions

Is it possible to create a Partial View, which has a controller, which can
Possible Duplicate: Create an alert on any view controller after Facebook request:didFailWithError: I have
Is it possible to create a filter in a Drupal 6 View that is
Possible Duplicate: Create shortcut to console.log() In javascript we can easy assign functions to
I need to create a view or a table valued function that returns one
I can't create layout in which I will have <LinearLayout> <TextView/> <ExpandableListView/> <Button/> </LinearLayout>
Is possible create an extension for SQL Management Studio in Visual Studio 2010? Visual
Hi it'd like to know if it's at all possible create a parametric equalizer
Possible Duplicate: Create provisioning profile in iphone application i developed my iphone app and
Possible Duplicate: Create event handler for OnScroll for web browser control 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.