More style, create dom, better class structure
This commit is contained in:
23
tagslice.js
23
tagslice.js
@@ -2,12 +2,33 @@
|
||||
|
||||
class TagSlice {
|
||||
constructor(container) {
|
||||
this.buildDom_(container);
|
||||
this.loadJson_();
|
||||
}
|
||||
|
||||
buildDom_(container) {
|
||||
let outer = document.createElement('outer');
|
||||
container.appendChild(outer);
|
||||
|
||||
let taglist = document.createElement('taglist');
|
||||
outer.appendChild(taglist);
|
||||
taglist.innerText = 'tag!';
|
||||
|
||||
let objectlist = document.createElement('objectlist');
|
||||
outer.appendChild(objectlist);
|
||||
}
|
||||
|
||||
loadJson_() {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'tagslice.json');
|
||||
xhr.responseType = 'json';
|
||||
xhr.onload = () => {
|
||||
console.log(xhr.response);
|
||||
this.onJsonLoad_(xhr.response);
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
onJsonLoad_(response) {
|
||||
console.log('foo', response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user