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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:38:38+00:00 2026-06-15T14:38:38+00:00

The following are some of my coffeescript code class Floor extends Backbone.Model defaults: array:[]

  • 0

The following are some of my coffeescript code

class Floor extends Backbone.Model
    defaults:
        "array":[]

    initialize: ->
        a = []
        for i in [0..10] by 1
            tmp = {
                x: i*10,
                y: i*10
            }
            a.push(tmp)
        this.set('array', a)

class FloorView extends Backbone.View
    initialize: ->
        this.model.on('change:array', this.renderArray, this) 

    renderArray: ->
        console.log 'Do something'
        return this

floor1 = new Floor
floorView = new floorView({ model:floor1})

The following three lines are not fire the change event calling renderArray
method

array = floor1.get('array')
array[0].x = 1000;
floor1.set('array',array)

but the following code actually call the renderArray method

floor1.set('array',{});

is there any method to detect property changed of an object in an array?

or what I have done wrong?

  • 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-15T14:38:39+00:00Added an answer on June 15, 2026 at 2:38 pm

    You can think about it this way: “array” is a variable name that points to an array. When you do this:

    floor1.set('array', []);
    

    You are pointing “array” to a completely different array. However, when you do this:

    array = floor1.get('array')
    array[0].x = 1000;
    floor1.set('array', array)
    

    You are updating the array that “array” already points to. In other words, you are not changing the array that “array” points to. Instead, you are modifying a value within the existing array.

    This Q&A has more backround: Backbone.js : change not firing on model.change()

    And points out this work around:

    array = floor1.get('array')
    array[0].x = 1000;
    floor1.set('array', array)
    floor1.trigger('change:array')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code inside a class. (It's coffeescript-- and it's for a
I have some coffeescript like the following: class foo: @bar = 'bob loblaw' processRows:
I was following some Java code to do image processing on bitmaps and found
I tried following some of the code from here and here , but I
Following some example code on the net, I got my first WiX installer to
Following some code in Agile Web Development book, theres a method to redirect back
I am following some tutorials and came up with the following code: // rendering.cpp
(This question has been rewritten from an issue with NSTextView following some further research)
I have the following in my coffeescript/backbone app. The problem is it's running console.log
Following some examples, I have a function that gets triggered on the 'register_deactivation_hook'. This

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.