Initial Commit ES6 barebone
This commit is contained in:
13
src/index.js
Normal file
13
src/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import Backbone from 'backbone';
|
||||
import TestView from './view';
|
||||
import _ from 'underscore';
|
||||
|
||||
Backbone.history.start();
|
||||
|
||||
class Index {
|
||||
constructor() {
|
||||
new TestView();
|
||||
}
|
||||
}
|
||||
|
||||
new Index();
|
||||
26
src/myview.js
Normal file
26
src/myview.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import Backbone from 'backbone';
|
||||
import * as _ from 'underscore';
|
||||
import $ from 'jquery';
|
||||
import Mustache from 'mustache';
|
||||
|
||||
|
||||
export default class MyView extends Backbone.View {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.el = '#myarea';
|
||||
this.$el = $(this.el);
|
||||
this.template = 'Hello';
|
||||
this.render();
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log(this.el)
|
||||
this.$el.html(Mustache.render(this.template));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
28
src/view.js
Normal file
28
src/view.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import Backbone from 'backbone';
|
||||
import * as _ from 'underscore';
|
||||
import $ from 'jquery';
|
||||
import Mustache from 'mustache';
|
||||
import MyView from './myview';
|
||||
|
||||
|
||||
export default class TestView extends Backbone.View {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.el = 'li';
|
||||
this.$el = $(this.el);
|
||||
this.template = '<div id="myarea"></div>'
|
||||
this.render();
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log(this.el)
|
||||
this.$el.html(Mustache.render(this.template));
|
||||
new MyView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user