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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:39:48+00:00 2026-06-09T10:39:48+00:00

* UPDATE : See final answer code in the last code block below. *

  • 0

*UPDATE: See final answer code in the last code block below.*

Currently I am having an issue displaying a collection in a collection view. The collection is a property of an existing model like so (pseudo code)

ApplicationVersion { Id: 1, VersionName: "", ApplicationCategories[] }

So essentially ApplicationVersion has a property called ApplicationCategories that is a javascript array. Currently when I render the collection view associated with ApplicationCategories nothing is rendered. If I debug in Chrome’s javascript debugger it appears that the categories have not been populated yet (so I assume ApplicationVersion has not been fetched yet). Here is my code as it stands currently

ApplicationCategory Model, Collection, and Views

ApplicationModule.ApplicationCategory = Backbone.Model.extend({
    urlRoot:"/applicationcategories"
});

ApplicationModule.ApplicationCategories = Recruit.Collection.extend({
    url:"/applicationcategories",
    model:ApplicationModule.ApplicationCategory,

    initialize: function(){
        /*
         * By default backbone does not bind the collection change event to the comparator
         * for performance reasons.  I am choosing to not preoptimize though and do the
         * binding.  This may need to change later if performance becomes an issue.
         * See https://github.com/documentcloud/backbone/issues/689
         *
         * Note also this is only nescessary for the default sort.  By using the
         * SortableCollectionMixin in other sorting methods, we do the binding
         * there as well.
         */
        this.on("change", this.sort);
    },

    comparator: function(applicationCategory) {
        return applicationCategory.get("order");
    },

    byName: function() {
        return this.sortedBy(function(applicationCategory) {
            return applicationCategory.get("name");
        });
    }
});

_.extend(ApplicationModule.ApplicationCategories.prototype, SortableCollectionMixin);

ApplicationModule.ApplicationCategoryView = Recruit.ItemView.extend({
    template:"application/applicationcategory-view-template"
});

ApplicationModule.ApplicationCategoriesView = Recruit.CollectionView.extend({
    itemView:ApplicationModule.ApplicationCategoryView
});

ApplicationCategory template

<section id="<%=name%>">
   <%=order%>
</section>

ApplicationVersion Model, Collection, and Views

ApplicationModule.ApplicationVersion = Backbone.Model.extend({
    urlRoot:"/applicationversions"
});

ApplicationModule.ApplicationVersions = Recruit.Collection.extend({
    url:"/applicationversions",
    model:ApplicationModule.ApplicationVersion
});

ApplicationModule.ApplicationVersionLayout = Recruit.Layout.extend({
    template:"application/applicationversion-view-template",

    regions: {
        applicationVersionHeader: "#applicationVersionHeader",
        applicationVersionCategories: "#applicationVersionCategories",
        applicationVersionFooter: "#applicationVersionFooter"
    }
});

ApplicationModule.ApplicationVersionController = {
    showApplicationVersion: function (applicationVersionId) {
        ApplicationModule.applicationVersion = new ApplicationModule.ApplicationVersion({id : applicationVersionId});

        var applicationVersionLayout = new Recruit.ApplicationModule.ApplicationVersionLayout({
            model:ApplicationModule.applicationVersion
        });

        ApplicationModule.applicationVersion.fetch({success: function(){
            var applicationVersionCategories = new Recruit.ApplicationModule.ApplicationCategoriesView({
                collection: ApplicationModule.applicationVersion.application_categories
            });
            applicationVersionLayout.applicationVersionCategories.show(applicationVersionCategories);
        }});

        // Fake server responds to the request
        ApplicationModule.server.respond();

        Recruit.layout.main.show(applicationVersionLayout);
    }
};

Here is my ApplicationVersion template

<section id="applicationVersionOuterSection">
<header id="applicationVersionHeader">
    Your Application Header <%= id %>
</header>
<section id="applicationVersionCategories">
</section>
<footer id="applicationVersionFooter">
     Your footer
</footer>

One thing to note I am currently using Sinon to mock my server response, but I don’t think this is causing the issues as it is responding with the information as I expect looking through the javascript debugger (and like I said it is displaying ApplicationVersion id correctly). I can provide this code as well if it helps

It is currently displaying the application version id (id in the template), so I know it is fetching the data correctly for normal properties, it just is not rendering my ApplicationCategories javascript array property.

So ultimately I am binding to the success of the fetch for ApplicationVersion, then setting up the view for the ApplicationCategories. Since this isn’t working like I expect I am wondering if there is a better way to create this collection view?

Thanks for any help

UPDATE: Working code example that Derek Bailey lead me too.

ApplicationModule.ApplicationVersionController = {
    showApplicationVersion: function (applicationVersionId) {
        ApplicationModule.applicationVersion = new ApplicationModule.ApplicationVersion({id : applicationVersionId});

        var applicationVersionLayout = new Recruit.ApplicationModule.ApplicationVersionLayout({
            model:ApplicationModule.applicationVersion
        });

        ApplicationModule.applicationVersion.fetch();

        // Fake server responds to the request
        ApplicationModule.server.respond();

        Recruit.layout.main.show(applicationVersionLayout);

        var applicationVersionCategories = new Recruit.ApplicationModule.ApplicationCategoriesView({
            collection: new Backbone.Collection(ApplicationModule.applicationVersion.get('application_categories'))
        });
        applicationVersionLayout.applicationVersionCategories.show(applicationVersionCategories);
    }
};
  • 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-09T10:39:50+00:00Added an answer on June 9, 2026 at 10:39 am

    Marionette’s CollectionView requires a valid Backbone.Collection, not a simple array. You need to create a Backbone.Collection from your array when passing it to the view:

    
    new MyView({
      collection: new Backbone.Collection(MyModel.Something.ArrayOfThings)
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE see below I am not sure how to populate a list or vector
OK, I thought I would try one last update and see if it gets
UPDATE (spoiler): This question is answered (see David Carlisle answere below) and it looks
Update: question now contains the final edited answer! I now use the following (final
solved, see my FINAL ANSWER post for complete details on what worked for me
UPDATED: I've updated the code based on the correct answer below. This works but
Update: See the bottom of this question for a C# workaround. Hi there, Consider
(Please see update at bottom) I've looked at dozens of questions and haven't been
Update: OK I see it's a bubble sort, but is it less efficient because
Update Solution Found See Bottom of post if interested Seems simple enough and for

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.