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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:36:17+00:00 2026-06-17T03:36:17+00:00

Here is my Backbone: App.Models.Count = Backbone.Model.extend({ url: this.url, initialize: function() { this.fetch({ success:

  • 0

Here is my Backbone:

App.Models.Count = Backbone.Model.extend({
        url: this.url,
        initialize: function() {
            this.fetch({
                success: function(data, response) {
                    this.count = data.get('count');
                    console.log(this.count);  // 9, correct answer
                }
            });
        }
    });

    App.Views.Count = Backbone.View.extend({
        tagName: 'span',
        initialize: function(options) {
            this.count = this.options.count;
            console.log(options);  // returns correctly
            this.model.on('reset', this.render, this);
        },
        render: function() {
            console.log('test'); // not called
            this.$el.html(this.model.toJSON());
            return this;
        }
    });

And in my route:

var mc = new (App.Models.Count.extend({'url' : 'main-contact-count'}))();
var mcv = new (App.Views.Count.extend({ model: mc }))();
console.log(mcv); // 9, correct answer
$('#contactCount').html(mcv);

As you can see, my render method is never called. Also, it seems that my view is being called before my model, based on what I see console.log’d in Firebug. Is that because of the async? Why isn’t render being called?

  • 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-17T03:36:18+00:00Added an answer on June 17, 2026 at 3:36 am

    You’re using Backbone in a funky way. Here’s the more standard way to do this:

    App.Models.Count = Backbone.Model.extend({
        urlRoot: "main-contact-count"
    });
    
    App.Views.Count = Backbone.View.extend({
        tagName: 'span',
        initialize: function(options) {
            this.model.on('change', this.render, this);
        },
        render: function() {
            console.log('test');
            this.$el.html(this.model.toJSON());
            return this;
        }
    });
    

    And in the router:

    var mc = new App.Models.Count();
    var mcv = new App.Views.Count({model: mc});
    mc.fetch();
    $('#contactCount').html(mcv.el);
    

    EDIT

    It turns out you’re listening to “reset” on a Backbone model. This will never happen. Try listening on “change” instead of reset:

    this.model.on('change', this.render, this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my Backbone.js: (function() { window.App = { Models: {}, Collections: {}, Views: {},
Here is my Model View and Collection : window.Report = Backbone.Model.extend({}); window.ReportCollection = Backbone.Collection.extend({
I have Backbone App Here are codes : This is Main.coffee : require [App/app,backbone]
Here is my view: define([ 'jquery', 'underscore', 'backbone', 'models/tableModel', 'collections/tablesCollection', 'views/tablesView' ], function($, _,
Here is the code in a function I'm trying to revise. This example works
I am building my first Backbone app with similar structure to this Todo MVC
In my current Backbone app, I have no problems creating or destroying models. The
I am using backbone.js here is my scenario Lets say I have a view
I'm being a little lazy here but are these (below) all the default Backbone
I am using the backbone-boilerplate, which you can find here . I was wondering

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.