Introduction
This article explains the View and router in backbone. In this article we will create Route.js, view.js, Model.js and index.html files. We know that backbone is a Single Page Application. It is a lightweight framework that helps to create the structure of the JavaScript in Model View Controller.
View: The View is the user interface but in the backbone it is not only the View but it is also the controller for connecting the model to the data interaction. So the backbone is called the Model View (MV) framework.
Router: The Router manages the URL based navigation in backbone. Most of the web application gives the linkable, sharable URLs for the relevant locations in the application. There is a # 'hash' fragment for this URL. In backbonejs there are methods given by this for routing and connecting the client-side web pages to the events and actions.
Now let's see the example of the View and Router in Backbone.JS.
Step 1
First we create a web application using the following:
- Start Visual Studio 2013.
- From the Start window select "New Project".
- Select "Installed" -> "Template" -> "Visual Studio" -> "Web" -> "Visual Studio 2012" and select "Web Application".

- Click on the "OK" button.
Step 2
Now we need to add a HTML Page in the Project:
- In the "Solution Explorer".
- Right-click on the project and select "Add" -> "HTML Page".

- Change the Name of the HTML page.

- Click on the "Add" button.
Add the following code:
<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script src="scripts/backbone-min.js"></script>
<script src="scripts/jquey-1.6.4.min.js"></script>
<script src="scripts/underscore-min.js"></script>
</head>
<body>
<div data-role="page">
<header data-role="header" class="navbar nav navbar-inner">
<h1>Backbone JS router Example</h1>
</header>
<div id="container" data-role="content">
<button id="show_orders">
Display Orders
</button>
<div id="template-list">
<ul>
<li><a href="#"></a></li>
</ul>
</div>
</div>
</div>
<script src="scripts/backbone-min.js"></script>
<script src="scripts/jquey-1.6.4.min.js"></script>
<script src="scripts/underscore-min.js"></script>
<script src="scripts/Model.js" type="text/javascript"></script>
<script src="scripts/view.js" type="text/javascript"></script>
<script src="scripts/Route.js"></script>
</body>
</html>






Join the conversation! Your thoughts help the community grow.