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

  • Home
  • SEARCH
  • 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 8927985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:19:59+00:00 2026-06-15T08:19:59+00:00

I am trying to implement Backbone with backbone-relational. The Claim model: define([‘underscore’, ‘backbone’, ‘backbone-relational’,

  • 0

I am trying to implement Backbone with backbone-relational.

The Claim model:

define(['underscore', 'backbone', 'backbone-relational', 'models/User'], function(_, Backbone, relational, User) {
  var Claim = Backbone.RelationalModel.extend({

  relations: [{
      type: Backbone.HasOne,
      key: 'a_user',
      relatedModel: User
  }],

  defaults: {
  },

  initialize: function() {
  },

  clear: function() {
    this.destroy();
    this.view.remove();
  }

  });
  return Claim;
});

The User model is a duplicate but with no relations set.

Below is the collection object:

Object
_byCid: Object
_byId: Object
_callbacks: Object
currentPage: 1
firstPage: 1
information: Object
length: 3
models: Array[3]
0: Object
1: Object
    _callbacks: Object
    _deferProcessing: false
    _escapedAttributes: Object
    _isInitialized: true
    _pending: Object
    _permitsUsed: 0
    _previousAttributes: Object
    _queue: Object
    _relations: Array[1]
    _silent: Object
    attributes: Object
       _deleted: false
       _new: false
       a_user: Object
           _callbacks: Object
           _escapedAttributes: Object
           _isInitialized: true
           _pending: Object
           _permitsUsed: 0
           _previousAttributes: Object
           _queue: Object
           _relations: Array[0]
           _silent: Object
           attributes: Object
               _deleted: false
               _new: false
               already_in_save: false
               already_in_validation: false
               coll_claims: Array[0]
               coll_claims_partial: true
               created_at: "2012-12-12 09:00:00"
               email: "cloud.strife@test.com"
               firstname: "Cloud"
               id: 2
               lastname: "Strife"
               modified_at: "2012-12-12 09:00:00"
               modified_columns: Array[0]
               start_copy: false
               title: "Mr"
               validation_failures: Array[0]
               virtual_columns: Array[0]
               __proto__: Object
               changed: Object
               cid: "c4"
               collection: undefined
               id: 2
               __proto__: Object
               already_in_save: false
               already_in_validation: false
      created_at: "2012-12-12 09:00:00"
      fulfilment: "bank"
      id: 2
      manual: 0
      modified_at: "2012-12-12 09:00:00"
      modified_columns: Array[0]
      promotion_id: 1
      purchase_id: 2
      start_copy: false
      status: "pending"
      user_id: 2
      validation_failures: Array[0]
      virtual_columns: Array[0]
      __proto__: Object
      changed: Object
      cid: "c3"
  collection: Object
  id: 2
  __proto__: Object
  2: Object
  length: 3

So essentially there are 3 Claim models in the collection and each Claim model has a nested model of User at the attribute key a_user.

The template looks like:

<% _.each( claims, function( item ){ %>
    <tr>
        <td><%= item.get("id") %></td>
        <td><%= item.get("promotion_id") %></td>
        <td><%= item.get("a_user").get("firstname") %></td>
        <td><%= item.get("purchase_id") %></td>
    <td></td>
        <td><%= item.get("status") %></td>
        <td><%= item.get("created_at") %></td>
    </tr>
<% }); %>

However this results in the error:

TypeError: 'null' is not an object (evaluating 'item.get("a_user").get')

If I take it back to just item.get(“a_user”) it displays outputs [object Object]

I am just learning Backbone so any pointers are appreciated.

  • 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-15T08:20:01+00:00Added an answer on June 15, 2026 at 8:20 am

    You shouldn’t be using get within the template — Underscore templates work with JSON, not Backbone model objects (you pass the model to the template using template(model.toJSON())), so they should be evaluated using basic dot-notation:

    <tr>
        <td><%= item.id %></td>
        <td><%= item.promotion_id %></td>
    </tr>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement some sort of nested collections in a Backbone.Model To
I am trying to implement a search function for my website. When the user
I am trying to implement my version of the Instance Store in Backbone.js as
I’m trying backbone and playing with the model concept – something I’ve implemented without
I'm trying to set up my first Backbone Model that implements RESTful WCF services.
Ok well I'm trying implement something similar to the 'undo' function in many image
Trying to implement a function that will return a list of ints the represent
So I am trying to implement CRUD into my Backbone app by using the
Trying to implement what I thought was a simple concept. I have a user
I am trying to implement a simple Backbone app on top of RequireJS, but

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.