Hello Backbone.js
How do I make an hello backbone.js?
Via http://arturadib.com/hello-backbonejs/. What is a hello backbone.js? How do you make a hello backbone.js? This script and codes were developed by Christian Fleschhut on 11 August 2022, Thursday.
Hello Backbone.js - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Hello Backbone.js</title> <script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <p> <small> via <a href='http://arturadib.com/hello-backbonejs/'> http://arturadib.com/hello-backbonejs/ </a> </small>
</p>
<div id='app'></div>
<script id='tpl_list' type='text/template'> <p> <button class='btn btn-sm btn-info' id='add'> Add list item </button> </p> <ul></ul>
</script>
<script id='tpl_list_item' type='text/template'> <span> <%= part1 %> <%= part2 %> <i class='swap fa fa-arrows-h'></i> <i class='delete fa fa-trash-o'></i> </span>
</script> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Hello Backbone.js - Script Codes CSS Codes
body { padding: 20px;
}
.swap,
.delete { cursor: pointer;
}
Hello Backbone.js - Script Codes JS Codes
(function($) { // Model var Item = Backbone.Model.extend({ defaults: { part1: 'hello', part2: 'world' } }); // Collection var List = Backbone.Collection.extend({ model: Item }); // Views var ItemView = Backbone.View.extend({ tagName: 'li', template: _.template($('#tpl_list_item').html()), events: { 'click .swap': 'swap', 'click .delete': 'remove' }, initialize: function() { _.bindAll(this, 'render', 'unrender', 'swap', 'remove'); this.model.on('change', this.render); this.model.on('remove', this.unrender); }, render: function() { this.$el.html(this.template(this.model.attributes)); return this; }, unrender: function() { this.$el.remove(); }, swap: function() { var swapped = { part1: this.model.get('part2'), part2: this.model.get('part1') }; this.model.set(swapped); }, remove: function() { this.model.destroy(); } }); var ListView = Backbone.View.extend({ el: $('#app'), template: _.template($('#tpl_list').html()), events: { 'click #add': 'addItem' }, initialize: function() { _.bindAll(this, 'render', 'addItem', 'appendItem'); this.collection = new List(); this.collection.on('add', this.appendItem); this.counter = 0; this.render(); }, render: function() { this.$el.append(this.template()); return this; }, addItem: function() { this.counter++; var item = new Item(); item.set({ part2: item.get('part2') + ' ' + this.counter }); this.collection.add(item); }, appendItem: function(item) { var itemView = new ItemView({ model: item }); $('ul', this.el).append(itemView.render().el); } }); var listView = new ListView();
})(jQuery);
Developer | Christian Fleschhut |
Username | cfleschhut |
Uploaded | August 11, 2022 |
Rating | 3 |
Size | 3,017 Kb |
Views | 46,552 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Frontend Dev Skillset | 2,835 Kb |
Backbone.js Playground | 2,812 Kb |
AngularJS tutorial app | 4,565 Kb |
AngularJS comments form | 3,280 Kb |
Givie.io Logo in CSS | 2,552 Kb |
Bootstrap 3 Playground | 2,594 Kb |
HubSpot Odometer Quicktest | 2,641 Kb |
CSS3 loading spinner | 2,950 Kb |
Playing with firebase | 3,175 Kb |
Sass random fn | 4,849 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Glitchy Text Effect | Kescoe | 2,208 Kb |
UI Challenge - Budget Selector | AgentRR007 | 3,547 Kb |
Twitch JSON API | Jvhti | 2,808 Kb |
Roman Numerical Converter | Vhall_io | 2,102 Kb |
Animated css matrix type | NielsOeltjen | 3,484 Kb |
VerbalExpressions Converter | Cmalven | 2,607 Kb |
JavaScript constructors | Simboonlong | 2,415 Kb |
Working around OS X Dynamic Scrollbars | Jrjenk | 2,279 Kb |
Chuck Norris Background | Manz | 1,967 Kb |
Hello People | Danburrows | 2,365 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!