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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:05:45+00:00 2026-06-01T15:05:45+00:00

I have trouble keeping track of the properties of a Model instance. For example

  • 0

I have trouble keeping track of the properties of a Model instance. For example I have declarations such as:

MyModel = Backbone.Model.extend({});

Then in my views, I’m often doing something like:

var someVal = this.model.get('someProperty');

I was beginning the task of moving a View’s strings into constants by encapsulating them in an object and passing it as a second parameter to a View’s constructor, for example:

SchemaOptionsView = Backbone.View.extend(
    { /* Body of View here as usual */}, 
    {
        TEMPLATE: '#View-Template',
        INPUT_REQUIRED:'required'
    });

When I got to thinking, I could solve two problems by doing this with my Models:

MyModel = Backbone.Model.extend(
{ /* Body of Model here as usual */},
{
    PROPERTY_1 = 'p1',
    PROPERTY_2 = 'p2'
});

I could then use the constant to retrieve the property value:

var someVal = this.model.get(MyModel.PROPERTY_1);

This would allow me to clearly see the properties a Model instance contains, and also moves a string value into a constant in an appropriate place.

I have not seen this recommended or in any examples. Have I missed something? What do people think about this idea?

  • 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-01T15:05:46+00:00Added an answer on June 1, 2026 at 3:05 pm

    This is solving a non problem. Your models should have well defined attributes – we use the defaults hash to enumerate all the available attributes of our models. Not only does this provide a catalog of the attributes that a model possesses but it also provides a way to override a non-validated input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have trouble with an Android app keeping a partial wake lock on my
We have trouble with keeping apart our different configurations. Allow me to explain with
I have been having trouble keeping up with the list of changes in 1.3
I have been having trouble keeping the canvas/window from just expanding to the size
I have trouble figuring out why a simple division like this one always returns
We have trouble implementing a nice session mechanism in JSP. One of our requirement
I have trouble with strange behavior of for..in cycle in JavaScript. I have the
I have trouble doing this... You may want to get the same result as
I have trouble shooting at file download problem. In Chrome, the download works fine.
I have trouble accessing filestream via SqlFileStream. Sql server and IIS7 are on different

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.