var DetailsView = View.extend({ events: { }, action: "/api/thread/", keywordAction: "/api/keyword/", initialize: function(opt){ this.comments = new CommentsView ({ parent: this }) this.files = new FilesView ({ parent: this }) this.gallery = new GalleryView ({ parent: this }) this.threadbox = new ThreadBox ({ 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) if (data.thread.keyword) { $.get(this.keywordAction + data.thread.keyword, this.populateKeyword.bind(this)) } }, populateKeyword: function(data){ this.threadbox.load(data) }, success: function(){ window.location.href = "/index" }, })