Skip to content

Ability to declare a set of default attributes to a model #80

@joonas

Description

@joonas

As we were discussing on the IRC, I think it would be nice if you could somehow declare a set of default attributes for a model that would get automatically set to their associated values when a model is initialized.

I think the implementation could be something along the lines of what you suggested:

Backbone.Model.extend({ 
    defaultAttributes: {
        key: 'value',
        anotherKey: 'Its value'
    }
});

or even simpler:

Backbone.Model.extend({
    defaults: {
        key: 'value',
        anotherKey: 'Its value'
    }
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions