- Tutorial project using the Backbone.js library together with jQuery.
- Note: to open web links in a new window use: ctrl+click on link
- Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
- BackboneJS architecture contains the following modules −
- HTTP Request
- Router
- View
- Events
- Model
- Collection
- Data Source
- Some apps are too small to need building with an SPA framework such as Angular. The simplicity and interactivity of a jQuery-based application can be combined with the well-structured building blocks from Backbone.js to create interactive pages with code organization and structure.
- runs from
index.html
in browser.
EmployeeManager.Views.Employee = Backbone.View.extend(
{
tagName: 'li',
className: 'media col-md-6 col-lg-4',
template: _.template($('#tpl-contact').html()),
events: {
'click .delete-employee': 'onClickDelete'
},
initialize: function() {
this.listenTo(this.model, 'remove', this.remove);
},
render: function() {
var html = this.template(this.model.toJSON());
this.$el.append(html);
return this;
},
onClickDelete: function(e) {
e.preventDefault();
this.model.collection.remove(this.model);
}
}
);
- employees can be added and edited
- Status: Working. Delete function not working
- To-Do: Fix delete function. Delete button commented out
- This project is licensed under the terms of the MIT license.
- Repo created by ABateman, email: gomezbateman@yahoo.com