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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:16:12+00:00 2026-05-27T22:16:12+00:00

Just getting started with backbone, and I thought I was familiar with all the

  • 0

Just getting started with backbone, and I thought I was familiar with all the caveats around data binding. Turns out I’m not. If anyone has any ideas as to why the following collection isn’t being bound to the IndexView I’d be very appreciative. (Have tried both manually in the browser and in chrome console…untriggered console.log call confirms that render() is not being triggered)

From console, attempted call is:

window.router.project_view.options.projects.create({name: 'TestProject'})

The project is successfully created, but no call to render()

Router:

class Backbonescaffolddemo.Routers.CalendarsRouter extends Backbone.Router

  routes:
    ""           : "index"


  index: () ->

    @projects = new Backbonescaffolddemo.Collections.ProjectsCollection()
    ...
    @project_view = new Backbonescaffolddemo.Views.Projects.IndexView(projects: @projects)
    @task_view = new Backbonescaffolddemo.Views.Tasks.IndexView(tasks: @tasks)
    ...
    $('#projects').html(@project_view.render().el)

Collection/Model:

class Backbonescaffolddemo.Models.Project extends Backbone.RelationalModel
  paramRoot: 'project'

class Backbonescaffolddemo.Collections.ProjectsCollection extends Backbone.Collection
  model: Backbonescaffolddemo.Models.Project
  url: '/projects'

View:

Backbonescaffolddemo.Views.Projects ||= {}

class Backbonescaffolddemo.Views.Projects.IndexView extends Backbone.View
  template: JST["backbone/templates/projects/index"]

  id: "projects"

  initialize: () ->
    @options.projects.fetch()
    _.bindAll(this, 'addOne', 'addAll', 'render')
    @options.projects.bind('reset', @addAll)
    @options.projects.bind('save', @addAll)
    @options.projects.bind('change', @addAll)
    @options.projects.bind('change', @render)
    @options.projects.bind('create', @render)

  addAll: () ->
    @options.projects.each(@addOne)

  addOne: (project) ->
    view = new Backbonescaffolddemo.Views.Projects.ProjectView({model: project})
    $(@el).append(view.render().el)

  render: ->
    console.log 'render called'
    $(@el).html(@template(projects: @options.projects.toJSON()))
    return this
  • 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-27T22:16:12+00:00Added an answer on May 27, 2026 at 10:16 pm

    Adding a model to a collection, via create or by any other means, triggers an add event on that collection, not a create event. Change

    @options.projects.bind('create', @render)
    

    to

    @options.projects.bind('add', @render)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting started with flex and am using the SDK (not Flex
I am just getting started with APC to cache data and was wondering if
I'm just getting started on Sitecore DMS 2.0, and not sure if I understand
I am just getting started with the Facebook JavaScript SDK, all I want to
Just getting started with Backbone.js. Simply including Backbone (either dev/production versions) causes the error:
I am just getting started with Backbone.js , but it looks really interesting... Right
I'm just getting started with backbone, based on what I read, I couldn't tell
I am just getting started with Rails 3 and I do not quite understand
I'm just getting started with svn so please, help me out if I saw
Just getting started with backbone.js, and one of the things I've noticed is that

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.