chatroom.js 562 B

1234567891011121314151617181920
  1. /*global Backbone, _, window */
  2. const ChatRoom = Backbone.NativeView.extend({
  3. el: '.chatroom',
  4. initialize () {
  5. this.render();
  6. },
  7. render () {
  8. const xhr = new XMLHttpRequest();
  9. xhr.open('GET', 'chatroom.html', true);
  10. xhr.onload = () => {
  11. var parser = new DOMParser();
  12. var doc = parser.parseFromString(xhr.responseText, "text/html");
  13. this.el.innerHTML = doc.querySelector('.chatroom').innerHTML;
  14. window.renderAvatars(this.el);
  15. }
  16. xhr.send();
  17. }
  18. });