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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:24:49+00:00 2026-06-08T06:24:49+00:00

According the Composite View documentation in a Composite View the events reset , remove

  • 0

According the Composite View documentation in a
Composite View the events reset, remove and add are already bind to the collection.

Said that, why do I need to bind the reset event to render my CompositeView?

P.S.:
I am using Backbone.Marionette v0.9.1
Please see the code for more details (1), (2)
Actually the problem is about serializeData,
because when the render function is called from initialEvents the variable has_message is set to zero. so the ul.messages is not defined in the template.
How should I fix it?


(1)

var CompositeView = Marionette.CompositeView.extend({

    template: CompositeTemplate,

    itemView: messageView,

    initialize: function () {
        this.collection = new MessageCollection();
        this.collection.fetch();

        this.bindTo(this.collection, 'reset', this.render);
        // deleting the previous line 
        // I cannot see the collection rendered after the fetch.
    },

    serializeData: function () {
        return {
            has_messages: this.collection.length > 0
        };
    },


    appendHtml: function (collectionView, itemView) {
        collectionView.$el.find('ul.messages').append(itemView.el);
    }

});

(2)

// Template


{{#if has_messages }}
    <!-- list messages -->
    <ul class="list messages"></ul>
{{else}}
    no messages
{{/if}}
  • 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-08T06:24:51+00:00Added an answer on June 8, 2026 at 6:24 am

    The need to bind to “renset” yourself is because composite view binds the reset event to the collection rendering, not the entire composite view:

    https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.compositeview.md#events-and-callbacks

    The problem with your serializeData function is probably caused by a context problem. You need to change your event binding to this:

    this.bindTo(this.collection, 'reset', this.render, this);

    This will bind the context of the view with the event.

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

Sidebar

Related Questions

According to Hibernate documentation : After observing that arrays cannot be lazy , you
According MSDN, FxCop is an application that analyzes managed code assemblies (code that targets
According to docs at http://code.google.com/p/minify/wiki/UriRewriting $min_serveOptions['rewriteCssUris'] = false; I should be able to add
To build a composite application view in my application, with different regions, untill now,
According to what I've heard, integer values that are not the processor's word size
According to the documentation , socket_read() is supposed to return FALSE when the remote
According to connects documentation the session should expire when the browser is closed: By
According to this article I know, that DateTimePicker control does not reflect CurrentUICulture So,
According to C++11 9.1/7 (draft n3376) , a standard-layout class is a class that:
According to Boost documentation boost::mutex and boost::timed_mutex are supposed to be different. The first

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.