Backbone.js Playground
How do I make an backbone.js playground?
What is a backbone.js playground? How do you make a backbone.js playground? This script and codes were developed by Christian Fleschhut on 11 August 2022, Thursday.
Backbone.js Playground - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Backbone.js Playground</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" href="css/style.css">
</head>
<body> <div id="app"></div>
<script type="text/template" id="todo-tmpl"> <label> <input type="checkbox" <% if (complete) { print("checked"); } %>> <span class="<% if (complete) { print("complete"); } %>"> <strong><%= title %>:</strong> <%= description %> </span> </label> <a class="cancel">×</a>
</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.1.2/backbone-min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Backbone.js Playground - Script Codes CSS Codes
.todos { margin: 0; padding: 0; list-style: none;
}
.todos li { position: relative;
}
.todos label { display: block; margin: 0 0 1px 0; padding: 20px; background: #eee;
}
.todos .complete { text-decoration: line-through;
}
.todos .cancel { position: absolute; top: 50%; right: 20px; margin-top: -9px; font-weight: bold; cursor: pointer;
}
Backbone.js Playground - Script Codes JS Codes
// Models
var Appointment = Backbone.Model.extend();
// Collections
var AppointmentList = Backbone.Collection.extend({ url: 'https://codepen.io/cfleschhut/pen/dyGek.js', model: Appointment
});
// Views
var AppointmentView = Backbone.View.extend({ tagName: 'li', className: 'todo', template: _.template($('#todo-tmpl').html()), events: { 'click [type=checkbox]': 'toggleComplete', 'click .cancel': 'cancel' }, initialize: function() { this.model.on('change', this.render, this); this.model.on('remove', this.remove, this); }, render: function() { this.$el.html(this.template(this.model.toJSON())); return this; }, toggleComplete: function() { this.model.set({complete: !this.model.get("complete")}); }, cancel: function() { this.model.set({canceled: true}); this.collection.remove(this.model); }
});
var AppointmentListView = Backbone.View.extend({ tagName: 'ul', className: 'todos', initialize: function() { this.collection.on('sync', this.render, this); //this.collection.on('change', this.render, this); //this.collection.on('add', this.addOne, this); //this.collection.on('destroy', this.remove, this); }, render: function() { this.collection.forEach(this.addOne, this); return this; }, addOne: function(model) { var appointmentView = new AppointmentView({ model: model, collection: this.collection }); this.$el.append(appointmentView.render().el); }, remove: function() { this.$el.remove(); }
});
appointments = new AppointmentList();
appointments.fetch();
var appointmentListView = new AppointmentListView({ collection: appointments
});
$('#app').html(appointmentListView.el);
Developer | Christian Fleschhut |
Username | cfleschhut |
Uploaded | August 11, 2022 |
Rating | 3 |
Size | 2,812 Kb |
Views | 22,264 |
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 |
Givie.io Logo in CSS | 2,552 Kb |
Json data for todolist | 1,615 Kb |
CodeSchool Powering Up with React | 7,420 Kb |
AngularJS tutorial app | 4,565 Kb |
React-Bootstrap sandbox | 2,936 Kb |
Processing.js Playground | 2,392 Kb |
Vertical Tab Component | 3,878 Kb |
CSS3 loading spinner | 2,950 Kb |
Playing with firebase | 3,175 Kb |
Starting out with Ember.JS | 4,808 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 |
Vanilla JS - A toggleClass function | Woodwork | 2,532 Kb |
SVG email test v2.0 | M_J_Robbins | 2,090 Kb |
Svg animation draw | SzymonDziewonski | 5,545 Kb |
Fireworks Show | Arianalynn | 3,048 Kb |
Collapsing Widget | Er40 | 4,279 Kb |
Resizable SASS Icons | Marianarlt | 7,611 Kb |
A Pen by Paul Sullivan | Pwsm50 | 2,349 Kb |
Heatmap Color Scales | Stevepepple | 2,331 Kb |
Scifi-style Radio-based Tab | Aaronchuo | 4,427 Kb |
Ball Physics | Getsetbro | 3,149 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!