/
Detail.js
31 lines (23 loc) · 959 Bytes
/
Detail.js
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
31
define([],
function () {
// Using ECMAScript 5 strict mode during development. By default r.js will ignore that.
"use strict";
var DetailView = Backbone.View.extend({
template : _.template('<div class="id">Id: <%= id %></div><div class="title">Titolo: <%= title %></div><div class="text">Testo: <%= text %></div>'),
initialize : function () {
this.collection.bind("reset", this.render, this);
},
render : function () {
if (!this.options.detailId) {
return;
}
var reqInstance = this.collection.get(this.options.detailId);
if (!reqInstance) {
return;
}
this.el.html(this.template(reqInstance.toJSON()));
return this;
}
});
return DetailView;
});