backbone.jsHow do I use Backbone.js to create a wiki?
Backbone.js is a JavaScript library that can be used to create a wiki. To do so, you will need to create a Model, View, and Collection.
The Model will contain the data for each page and will be responsible for validating and persisting the data.
The View will be responsible for rendering the page and responding to user events.
The Collection will contain the list of pages and will be responsible for loading and saving the pages.
Example code
// Model
var Page = Backbone.Model.extend({
defaults: {
title: '',
content: ''
}
});
// View
var PageView = Backbone.View.extend({
render: function(){
this.$el.html(this.model.get('content'));
}
});
// Collection
var Pages = Backbone.Collection.extend({
model: Page
});
Helpful links
More of Backbone.js
- How do I organize the structure of a Backbone.js project?
- What is Backbone.js and how is it used?
- How do I use a template engine with Backbone.js?
- How do I determine the length of a collection in Backbone.js?
- How can I use Backbone.js, Fresco Play, and hands-on techniques to develop software?
- How can I use Backbone.js to wait for a fetch request to complete?
- How do I create a Backbone.js tutorial?
- How can I set a model in Backbone.js?
- How do I initialize a Backbone.js Model?
- How do I use Backbone.js to create a Hacker News-style application?
See more codes...