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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:29:34+00:00 2026-05-25T13:29:34+00:00

class TheModel extends Backbone.Model foo: #bar Entity = new TheModel(#pass in attributes) Can I

  • 0
class TheModel extends Backbone.Model
    foo: 
        #bar

Entity = new TheModel(#pass in attributes)

Can I then extend Entity and maintain the models attributes/state?

class User extends Entity
    foo: 
        super
        #more

EDIT:

class Entity extends Backbone.Model
    initialize: (options) ->
        @_events options

        _events: (options) -> 
            entity.bind 'foo'

class Entity1 extends Entity
    _events: (options) ->  
        super options
        entity.bind 'bar'

class Entity2 extends Entity
    _events: (options) -> 
        super options
        entity.bind 'baz'

#a new entity arrives, we don't know if he is type one or two yet so he is...
entity = new Entity

#now we find out he is type 2
entity = new Entity2(entity.attributes)
  • 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-25T13:29:34+00:00Added an answer on May 25, 2026 at 1:29 pm

    No. Having a class extend an object (rather than a function) doesn’t make sense. If you tried to instantiate your User class, you’d get the error

    TypeError: Cannot read property 'constructor' of undefined
    

    If you want to override the foo method on Entity, you should do so directly, though note that the super syntax won’t work. Instead, you should write

    entity.foo = ->
      @constructor::foo.apply arguments  # equivalent to super
      # ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var myView = Backbone.View.extend({ tagName: 'div', className: function() { return this.model.isNew() ? 'new' :
class Foo { static bool Bar(Stream^ stream); }; class FooWrapper { bool Bar(LPCWSTR szUnicodeString)
class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to
Here is my model_users class (the model it extends from doesn't have anything yet
Model : <?php class Blogm extends CI_Model{ function __construct() { // Call the Model
In my CakePHP application, I have a model like this: class Duck extends AppModel
Here's my model: <?php class Dbtest extends CI_Model { function __construct() { // Call
I have a criteria query not really working. Here the model: @Entity public class
I have a bus model, which has a nested route model. class Busables.Models.Bus extends
window.User = Backbone.Model.extend({ defaults: { name: 'Jane', friends: [] }, urlRoot: users, initialize: function(){

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.