JavaScript Backbone. js framework Environment setup and Hellow world example, backbone. jshellow
Environment preparation
Before learning about Backbone, you need to prepare something:
First, you need to get the Backbone framework source file: http://documentcloud.github.com/backbone/
Backbone relies on the underlying approach of the Underscore framework, so you also need to download the source file of the Underscore framework: http://documentcloud.github.com/underscore/
In Backbone, DOM and event operations depend on third-party libraries (such as jQuery or Zepto). You only need to select one of them for download:
JQuery: http://jquery.com/
Zepto: http://zeptojs.com/
It seems quite troublesome, but the purpose of Backbone is to use a simple framework to build complex applications, so it is not complicated.
You can create an HTML page and introduce these frameworks, like this:
<script type="text/javascript" src="jquery/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="underscore/underscore-min.js"></script> <script type="text/javascript" src="backbone/backbone-min.js"></script>
Now, you have prepared the environment required to run Backbone.
Hellow World
Let's take a look at the helloworld function: there is a report button on the page, click the pop-up input box, enter the content, confirm, and finally the content will be added to the page. The page is shown as follows:
Let's look at the code below:
<! DOCTYPE html>
I think the code is intuitive. This involves three parts of backbone: view, model, and collection. We will mention that model represents a data model, collection is a set of models, while view is used to process pages and simple page logic.