{"id":2829,"date":"2015-03-31T11:15:35","date_gmt":"2015-03-31T08:15:35","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=2829"},"modified":"2018-01-10T16:37:11","modified_gmt":"2018-01-10T14:37:11","slug":"backbone-js-events-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/","title":{"rendered":"Backbone.js Events Example"},"content":{"rendered":"<p>The purpose of this tutorial is to provide basic understanding of backbone.js along with its components. We\u00a0will be discussing that what backbone.js actually is and how it differs from other JavaScript libraries. In particular, we will be understanding its out of the box support for events with example.<\/p>\n<p>We will start from the very first step which is to set up a working environment for backbone.js to start working with it. Then we will provide a brief overview, explain the support for events and finally provide a comprehensive working example.<\/p>\n<p>Actually, this example will be completed step by step with the implementation of the component that we will be discussing, in order to give some proper insight and understanding of what you are reading.<\/p>\n<div class=\"tip\"><strong>Tip<\/strong><br \/>\nIf you already have BackeboneJS set up in your system, you may jump directly to the <a href=\"#intro\"><strong>Understanding BackboneJS<\/strong><\/a> below.<\/div>\n<p>[ulp id=&#8217;qGGDqWnle19VavkM&#8217;]<\/p>\n<h2>Setting up Working Environment for Backbone.js<\/h2>\n<p>BackboneJS has a hard dependency on Underscore.js and a soft dependency on Jquery. So, the following components are required to start working with BackboneJS:<\/p>\n<ol>\n<li><a title=\"Backbone.js\" href=\"http:\/\/backbonejs.org\/\" target=\"_blank\">Backbone.js<\/a><\/li>\n<li><a title=\"Underscore.js\" href=\"http:\/\/underscorejs.org\/\" target=\"_blank\">Underscore.js<\/a>\u00a0(&gt;=1.4.3)<\/li>\n<li><a title=\"Jquery\" href=\"http:\/\/jquery.com\/\" target=\"_blank\">Jquery<\/a>\u00a0(&gt;=1.7.0)<\/li>\n<\/ol>\n<p>So, after having all these prerequisites we will test if it has been set up properly by writing our first\u00a0BackboneJSDemo.html file such as below:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n &lt;meta charset=&quot;utf-8&quot;&gt;\r\n &lt;title&gt;BackboneJS Tutorial&lt;\/title&gt;\r\n &lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;script src=&quot;underscore.js&quot;&gt;&lt;\/script&gt;\r\n &lt;script src=&quot;jquery.js&quot;&gt;&lt;\/script&gt;\r\n &lt;script src=&quot;backbone.js&quot;&gt;&lt;\/script&gt;\r\n&lt;body&gt;\r\n&lt;html&gt;\r\n<\/pre>\n<p>The picture below shows the necessary files downloaded in order to start working.<\/p>\n<figure id=\"attachment_3136\" aria-describedby=\"caption-attachment-3136\" style=\"width: 959px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/Resized-LTSSA.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/Resized-LTSSA.jpg\" alt=\"Backbone.js Essential Files\" width=\"959\" height=\"204\" class=\"size-full wp-image-3136\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/Resized-LTSSA.jpg 959w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/Resized-LTSSA-300x64.jpg 300w\" sizes=\"(max-width: 959px) 100vw, 959px\" \/><\/a><figcaption id=\"caption-attachment-3136\" class=\"wp-caption-text\">Backbone.js Essential Files<\/figcaption><\/figure>\n<p><span id=\"intro\"><\/span>You can simply run the above\u00a0HTML file on browser to see that JS files have been loaded successfully or not.<\/p>\n<h2>Understanding BackboneJS<\/h2>\n<p>Like many other libraries, Backbone is also one of the most prominent JavaScript libraries. It provides proper structuring to web applications with its most robust components. BackboneJS is gaining special attention\u00a0due to the following attributes:<\/p>\n<ul>\n<li>It is simple and easy to use<\/li>\n<li>It is a light weight framework<\/li>\n<li>It is of object oriented Nature<\/li>\n<li>It provides structure to JavaScript that makes it easy to understand<\/li>\n<\/ul>\n<h2>Major Components of BackboneJS:<\/h2>\n<p>BackboneJS consists of different components that we will be discussing in detail below. The major components of BackboneJS are:<\/p>\n<ol>\n<li>Views<\/li>\n<li>Events<\/li>\n<li>Models<\/li>\n<li>Collections<\/li>\n<li>Routers<\/li>\n<\/ol>\n<h2>BackboneJS Views:<\/h2>\n<p>BackboneJS Views are used to reflect how our application model data will look like. They are also used to listen for different types on events based upon JavaScript selectors and act accordingly based upon the type of event fired. The sample code below describes how we can use views to render application&#8217;s model data:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar BackbonejsView= Backbone.View.extend({\r\n\r\nel: $('body'), \/\/ attaches `this.el` to an existing element.\r\n\r\n\/\/The initialize function is always called when instantiating a Backbone View.\r\n initialize: function(){\r\n _.bindAll(this, 'render'); \/\/ every function that uses 'this' as the current object should be in here\r\n this.render();\r\n },\r\n\r\nrender: function(){\r\n $(this.el).append(&quot;&lt;ul&gt; &lt;li&gt;Welcome to backboneJS JavaScript Library&lt;\/li&gt; &lt;\/ul&gt;&quot;);\r\n }\r\n\r\n });\r\n\r\n\/\/Instantiating Application View\r\nvar listView = new BackbonejsView();\r\n<\/pre>\n<p>So, the above example\u00a0simply shows that how the BackboneJS Views are used. For more details regarding BackboneJS Views please refer: <a title=\"BackboneJS Views in Detail\" href=\"http:\/\/documentcloud.github.io\/backbone\/#View\" target=\"_blank\">BackboneJS Views in Detail<\/a><\/p>\n<h2>BackboneJS Models:<\/h2>\n<p style=\"text-align: left\">Models are the heart of any JavaScript application. BackboneJS Model is basically a Java Script object, i.e. key-value pairs\u00a0used to represent our application data which can be created, validated with respect to specified constraints, saved to the server and destroyed. Models provide basic set of functionality\u00a0to handle event triggering, persistence, etc.\u00a0The following example elaborates on how we can use models in our application:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar Employee\u00a0= Backbone.Model.extend({\r\ndefaults: {\r\nname: 'bilal',\r\naddress: 'Pakistan'\r\n }\r\n });\r\n<\/pre>\n<p><span style=\"line-height: 1.5\">For more Details regarding BackboneJS Model please refer: <\/span><a style=\"line-height: 1.5\" title=\"BackboneJS Model in Detail\" href=\"http:\/\/documentcloud.github.io\/backbone\/#Model\" target=\"_blank\">BackboneJS Model in Detail<\/a><\/p>\n<h2>BackboneJS Collections:<\/h2>\n<p style=\"text-align: left\">BackboneJS Collections can be simply defined as a container which maintains the list of BackboneJS Models in an organized way.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar EmployeesList = Backbone.Collection.extend({\r\n\/\/Specifying the model class that the collection contains. Employee model has already been created in BackboneJS Model Section.\r\nmodel: Employee\r\n });\r\n\/\/Initializing Collection\r\nthis.collection = new ExployeesList();\r\n\/\/Adding Object in Collection\r\nthis.collection.add(employee);\r\n\/\/Iterating Whole Collections\r\n _(this.collection.models).each(function(employee){\r\n    \/\/Processing fetched object from collection\r\n }, this);\r\n<\/pre>\n<p style=\"text-align: left\">For more details regarding BackboneJS Collections please refer:\u00a0<a title=\"BackboneJS in Detail\" href=\"http:\/\/documentcloud.github.io\/backbone\/#Collection\" target=\"_blank\">BackboneJS Collections in Details<\/a><\/p>\n<h2>BackboneJS Routers:<\/h2>\n<p style=\"text-align: left\">Not heard about word routers before? Well, Routers were previously called controllers, before they got a change of name in BackboneJS version 0.5. So, Routers are basically a mechanism to route client side pages and connect them to events and actions through URLs. So if you want to make reference to certain state or location of a web application you need it.\u00a0Consider the following example to understand how we can use them:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar Workspace = Backbone.Router.extend({\r\n routes: {\r\n &quot;help&quot;: &quot;help&quot;, \/\/ #help\r\n &quot;search\/:query&quot;: &quot;search&quot;, \/\/ #search\/kiwis\r\n &quot;search\/:query\/p:page&quot;: &quot;search&quot; \/\/ #search\/kiwis\/p7\r\n },\r\n help: function() {\r\n ...\r\n },\r\n search: function(query, page) {\r\n ...\r\n }\r\n});\r\n<\/pre>\n<p>For more details regarding BackboneJS Routers please refer: <a title=\"BackboneJS Routers in Detail\" href=\"http:\/\/documentcloud.github.io\/backbone\/#Router\" target=\"_blank\">BackboneJS Routers in Detail<\/a><\/p>\n<h2>BackboneJS Events:<\/h2>\n<p>Events are one of the strong component of BackboneJS. Events are used to create a relationship between your application and browser features. Furthermore, It gives the ability to perform some action on happening something to object.<\/p>\n<p>We will be understanding Events by discussing its usages in different scenarios with examples.<\/p>\n<h3>BackboneJS DOM Events<\/h3>\n<p>All jQuery Events are valid for BackboneJS to bind. To use BackboneJS Events you need to define an attribute named &#8220;events&#8221; into your views with the following syntax:<\/p>\n<p><span style=\"color: #000000\"><span style=\"color: #3366ff\"><span class=\"str\">&#8220;event css-selector&#8221;<\/span> <span class=\"pun\">:<\/span> <span class=\"str\">&#8220;function&#8221;<\/span><\/span><\/span><\/p>\n<p>Where event is the kind of Event that you want to handle\/listen, then you need to add a blank space and use a css selector (as you do with jQuery), but remember that the scope of the bind will include only those elements that belongs to your View. function is a name of a method of your view, and must be passed as string.<\/p>\n<p>Let&#8217;s Consider an example to understand this thoroughly:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nvar EmployeeView= Backbone.View.extend({\r\n\r\nel: $('body'), \/\/ el attaches to existing element\r\n\r\n\/\/So, Here we are binding events on adding each employee. Whenever DOM object with id 'addEmployee' will be clicked a new employee record will be added and 'emplyeeAdded method will be called.\r\n\r\nevents: {\r\n\r\nclick #addEmployee: 'employeeAdded'\r\n},\r\n\r\ninitialize: function(){\r\n _.bindAll(this, 'render', 'empoyeeAdded');\r\n\r\nthis.counter = 0; \/\/ total number of employee\u00a0added\u00a0so far\r\n this.render();\r\n },\r\n\r\n\/\/render() now introduces a button to add a new employee on which we have binded an event above\r\n\r\nrender: function(){\r\n $(this.el).append(&quot;&lt;button id='addEmployee'&gt;Add list item&lt;\/button&gt;&quot;);\r\n $(this.el).append(&quot;&lt;ul&gt;&lt;\/ul&gt;&quot;);\r\n },\r\n\r\n\/\/Function that will be called each time a new employee will be added\r\nempoyeeAdded: function(){\r\n this.counter++;\r\n $('ul', this.el).append(&quot;&lt;li&gt;Employee Added with id: &quot;+this.counter+&quot;&lt;\/li&gt;&quot;);\r\n },\r\n\r\n});\r\n\r\nvar employeeView= new EmployeeView();\r\n\r\n<\/pre>\n<p>Here you can have\u00a0<a href=\"http:\/\/api.jquery.com\/category\/events\/\">All Possible Events Categories<\/a>\u00a0for detailed understanding of Events Usages.<\/p>\n<p>We can also bind events on objects level as well, such as:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nevents: {\r\n'click' : 'confirmation'\r\n }\r\n\r\nconfirmation: function(){\r\n alert(&quot;Employee Added Successfully...!!!&quot;);\r\n }\r\n\r\n<\/pre>\n<p>So, whenever any object is clicked, this call back method will be called.<\/p>\n<h3>Model Binding Events<\/h3>\n<p>Usually a view tracks a model, and when the data in the model changes the view is updated to represent the changes.\u00a0But our views did not track models and were not updated when the model changed. So, we will have to track changes to the models so that we may change our models too accordingly. Hence here the role of bindings events to our models comes into play. So, we will be attaching events with change of our models which will invoke methods to change our view as well accordingly.<\/p>\n<p>Let&#8217;s consider an example about how can we bind events to model and change the views accordingly whenever there is any change in the model:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\n\/\/Here we have Employee Model\r\nvar Employee\u00a0= Backbone.Model.extend({\r\n defaults: {\r\nname: 'BAY',\r\ngender: 'male'\r\n }\r\n });\r\n\r\n\/\/Collection of Employees\r\nvar EmployeeList = Backbone.Collection.extend({\r\n model:\u00a0Employee\r\n });\r\n\r\n\/\/In our initialize method we will bind events to change in models\r\ninitialize: function(){\r\n\r\n _.bindAll(this, 'render', 'unrender'); \/\/ every function that uses 'this' as the current object should be in here\r\n\r\n\/\/Binding for events whenever any model object will be changed, to change view also\r\nthis.model.bind('change', this.render);\r\n\r\n\/\/Binding for events whenever any model object will be removed, to change view also\r\n this.model.bind('remove', this.unrender);\r\n }\r\n\r\n\/\/This method will update the view when model object will \u00a0be removed\r\n unrender: function(){\r\n $(this.el).remove();\r\n }\r\n\r\n\/\/To update the view when model object will be changed to show the updated values\r\n render: function(){\r\n\r\n $(this.el).html('&lt;span style=&quot;color:black;&quot;&gt;'+this.model.get('name')+' '+this.model.get('gender')+'&lt;\/span&gt;');\r\n return this; \/\/ for chainable calls, like .render().el\r\n },\r\n\r\n<\/pre>\n<p>For more details regarding BackboneJS Events\u00a0please refer to: <a title=\"BackboneJS Events in Detail\" href=\"http:\/\/documentcloud.github.io\/backbone\/#Events\">BackboneJS Events\u00a0in Detail<\/a><\/p>\n<h2>Download the Sample Application Source Code<\/h2>\n<p>In this article we created some sample applications starting from a very basic one, covering all the BackboneJS components.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a title=\"BackboneJS Sample Applications\" href=\"http:\/\/webcodegeeks.javacodegeeks.netdna-cdn.com\/wp-content\/uploads\/2015\/03\/BackboneJS-Examples.rar\">BackboneJS Sample Applications<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The purpose of this tutorial is to provide basic understanding of backbone.js along with its components. We\u00a0will be discussing that what backbone.js actually is and how it differs from other JavaScript libraries. In particular, we will be understanding its out of the box support for events with example. We will start from the very first &hellip;<\/p>\n","protected":false},"author":59,"featured_media":915,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-2829","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-backbone-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Backbone.js Events Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The main objective of this tutorial is to provide basic understanding of BackboneJS, It&#039;s Components and It&#039;s usages from start to bottom.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Backbone.js Events Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The main objective of this tutorial is to provide basic understanding of BackboneJS, It&#039;s Components and It&#039;s usages from start to bottom.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/BilalAhmedYaseen\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-31T08:15:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-10T14:37:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Bilal Ahmed Yaseen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BilalAhmedY\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bilal Ahmed Yaseen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/\"},\"author\":{\"name\":\"Bilal Ahmed Yaseen\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/0b4dca1e1bffb89bb6edb01013d3cd3f\"},\"headline\":\"Backbone.js Events Example\",\"datePublished\":\"2015-03-31T08:15:35+00:00\",\"dateModified\":\"2018-01-10T14:37:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/\"},\"wordCount\":1603,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"articleSection\":[\"Backbone.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/\",\"name\":\"Backbone.js Events Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"datePublished\":\"2015-03-31T08:15:35+00:00\",\"dateModified\":\"2018-01-10T14:37:11+00:00\",\"description\":\"The main objective of this tutorial is to provide basic understanding of BackboneJS, It's Components and It's usages from start to bottom.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Backbone.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/backbone-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Backbone.js Events Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/0b4dca1e1bffb89bb6edb01013d3cd3f\",\"name\":\"Bilal Ahmed Yaseen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19b263e3e1e552cee6dcc3ba8946c4455a0d872156c2fa1418599dc5ce3d6761?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19b263e3e1e552cee6dcc3ba8946c4455a0d872156c2fa1418599dc5ce3d6761?s=96&d=mm&r=g\",\"caption\":\"Bilal Ahmed Yaseen\"},\"description\":\"Bilal is professional, experienced and qualified software engineer involved in the design and development of various business and enterprise applications. He has best problem-solving, imaginative, innovative and excellent communication skills. He graduated from One of the most prominent University of Pakistan, Punjab University College of Information and Technology. He works as a Software Engineer in the multinational organization where he is mainly involved in the enterprise applications based on Java, Groovy &amp; Grails and MySQL Server.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\",\"https:\/\/www.facebook.com\/BilalAhmedYaseen\",\"http:\/\/www.linkedin.com\/pub\/bilal-ahmed-yaseen\/3a\/977\/691\",\"https:\/\/x.com\/BilalAhmedY\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/bilal-yaseen\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Backbone.js Events Example - Web Code Geeks - 2026","description":"The main objective of this tutorial is to provide basic understanding of BackboneJS, It's Components and It's usages from start to bottom.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/","og_locale":"en_US","og_type":"article","og_title":"Backbone.js Events Example - Web Code Geeks - 2026","og_description":"The main objective of this tutorial is to provide basic understanding of BackboneJS, It's Components and It's usages from start to bottom.","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/BilalAhmedYaseen","article_published_time":"2015-03-31T08:15:35+00:00","article_modified_time":"2018-01-10T14:37:11+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","type":"image\/jpeg"}],"author":"Bilal Ahmed Yaseen","twitter_card":"summary_large_image","twitter_creator":"@BilalAhmedY","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Bilal Ahmed Yaseen","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/"},"author":{"name":"Bilal Ahmed Yaseen","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/0b4dca1e1bffb89bb6edb01013d3cd3f"},"headline":"Backbone.js Events Example","datePublished":"2015-03-31T08:15:35+00:00","dateModified":"2018-01-10T14:37:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/"},"wordCount":1603,"commentCount":2,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","articleSection":["Backbone.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/","name":"Backbone.js Events Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","datePublished":"2015-03-31T08:15:35+00:00","dateModified":"2018-01-10T14:37:11+00:00","description":"The main objective of this tutorial is to provide basic understanding of BackboneJS, It's Components and It's usages from start to bottom.","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbone-js-events-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Backbone.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/backbone-js\/"},{"@type":"ListItem","position":4,"name":"Backbone.js Events Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/0b4dca1e1bffb89bb6edb01013d3cd3f","name":"Bilal Ahmed Yaseen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19b263e3e1e552cee6dcc3ba8946c4455a0d872156c2fa1418599dc5ce3d6761?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19b263e3e1e552cee6dcc3ba8946c4455a0d872156c2fa1418599dc5ce3d6761?s=96&d=mm&r=g","caption":"Bilal Ahmed Yaseen"},"description":"Bilal is professional, experienced and qualified software engineer involved in the design and development of various business and enterprise applications. He has best problem-solving, imaginative, innovative and excellent communication skills. He graduated from One of the most prominent University of Pakistan, Punjab University College of Information and Technology. He works as a Software Engineer in the multinational organization where he is mainly involved in the enterprise applications based on Java, Groovy &amp; Grails and MySQL Server.","sameAs":["http:\/\/www.webcodegeeks.com\/","https:\/\/www.facebook.com\/BilalAhmedYaseen","http:\/\/www.linkedin.com\/pub\/bilal-ahmed-yaseen\/3a\/977\/691","https:\/\/x.com\/BilalAhmedY"],"url":"https:\/\/www.webcodegeeks.com\/author\/bilal-yaseen\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/59"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=2829"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2829\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/915"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=2829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=2829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=2829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}