summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/details/index.js
blob: d7fb26f0c950e2cbe8bd11ef822bd38ed5c4f9ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var DetailsView = View.extend({

  events: {
  },
  
  action: "/api/thread/",
  
  initialize: function(opt){
    this.comments = new CommentsView ({ parent: this })
    this.files = new FilesView ({ parent: this })
    this.gallery = new GalleryView ({ parent: this })
  },
  
  load: function(id){
    id = id.replace(/\D/g, "")
    $.get(this.action + id, this.populate.bind(this))
  },
  
  populate: function(data){
    $("h1").html(data.thread.title)
    this.comments.load(data.comments)
    this.files.load(data.files)
    this.gallery.load(data.files)
  },
  
  success: function(){
    window.location.href = "/index"
  },

})