You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$10
For Premium members:
This article provides a simple sample of backbone.js. This samle only displays Hello World using backbone.js.
Introduction
This article provides a simple sample of backbone.js. This samle only displays "Hello World" using backbone.js.
In my previous article I introduced backbone.js, it is a JavaScript library. It is another JavaScript framework for creating MVC applications. It is used for client-side applications. Here we need to create two files, the first is "Hello.html" and the second is "Hello.js".
Use the following procedure to create the simple sample of backbone.js in an ASP.NET web application.
And use this following code:
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Simple backbone Example</title></head><body><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script><script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script><script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js"></script><script src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script><script src="Hello.js" type="text/javascript"></script></body></html>
Add the following code:
(function ($) {var ListView = Backbone.View.extend({el: $('body'),initialize: function () {_.bindAll(this, 'render');this.render();},render: function () {$(this.el).append("<ul> <li>hello world</li> </ul>");}});var listView = new ListView();})(jQuery);
In the code above there is a method explaining that initialization() is automatically called at the time of instantiation. Where we make all types of binding, excluding only UI events such as click.
Execute the application:
Voice of a Developer: JavaScript From Scratch