Introduction
Welcome to the "Demonstrate Backbone.js" article series. This article demonstrates how to create and use a Model in Backbone.js. This article starts with the concept of Backbone.js and various components of it. In our previous articles we saw an Introduction to Backbone.js and in Part 1, Part 2, Part 3, Part 4 and Part 5 the model implementation that you can get from here.
- Introduction of Backbone.js
- Demonstrating Backbone.js: Implement Model
- Demonstrating Backbone.js: Implement Model Part 2
- Demonstrating Backbone.js: Implement Model Part 3
- Demonstrating Backbone.js: Implement Model Part 4
- Demonstrating Backbone.js: Implement Model Part 5
In this part we will see more of Model implementation in Backbone.js.
Default property using prototype attribute
In this part we will learn the default property of the Model class using the prototype attribute. In the following Model implementation we have defined two properties of the “Product” model called name and manufacturer then we are accessing those default properties by the prototype property. Have a look at the following snippet.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JavaScript.aspx.cs" Inherits="JavaScript.JavaScript" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script src="backbone/Jquery.js"></script>
<script src="backbone/underscore-min.js"></script>
<script src="backbone/backbone-min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<script>
var Product = Backbone.Model.extend({
defaults: {
name: 'Xperia',
manufacturer: 'Sony'
}
});
console.log('Access name by prototype:- ' + Product.prototype.defaults.name);
console.log('Access manufacturer by prototype:- ' + Product.prototype.defaults.manufacturer);
</script>



Join the conversation! Your thoughts help the community grow.