Open In App

Backbone.js id Model

Last Updated : 15 Jun, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The Backbone.js id model is used to identify the unique identifier in a model. We can set it manually and later it is stored in a server.

Syntax:

Backbone.Model.id

Parameters: It does not accept any parameter.

Using the CDN Link: A content delivery network is a network that serves files to users. Here are the CDNs for Backbone.js

<script src=”https://code.jquery.com/jquery-2.1.3.min.js” type=”text/javascript”></script>  
<script src=”http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js” type=”text/javascript”></script>  <script src=”http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js” type=”text/javascript”></script>

Example 1: This example specifies the bookid as a unique identifier in the book model.

HTML




<!DOCTYPE html>
<html>
  
<head>
         type="text/javascript"></script>
    <script src=
        type="text/javascript"></script>
    <script src=
        type="text/javascript"></script>
  
    <script type="text/javascript">
        var Books = Backbone.Model.extend();
        var book = new Books({ 
            bookid: 23, 
            price: 678, 
            book_name: 'php' 
        });
          
        document.write("ID: ", book.get('bookid'));  
    </script>
</head>
  
<body></body>
  
</html>


Output:

ID: 23

Example 2: This example specifies the book_name as a unique identifier in the book model.

HTML




<!DOCTYPE html>
<html>
  
<head>
         type="text/javascript"></script>
    <script src=
        type="text/javascript"></script>
    <script src=
        type="text/javascript"></script>
  
    <script type="text/javascript">
        var Books = Backbone.Model.extend();
        var book = new Books({ 
            bookid: 23, 
            price: 678, 
            book_name: 'php' 
        });
          
        document.write("Name: ", book.get('book_name'));  
    </script>
</head>
  
<body></body>
  
</html>


Output:

Name: php


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads