49 lines
1.3 KiB
JavaScript
Executable File
49 lines
1.3 KiB
JavaScript
Executable File
// js/modules/dashboard.js
|
|
// Module reference argument, assigned at the bottom
|
|
|
|
(function (Dashboard) {
|
|
|
|
// Dependencies
|
|
var Util = app.module("util");
|
|
var Room = app.module("room");
|
|
|
|
Dashboard.Model = Backbone.Model.extend({
|
|
defaults: {
|
|
rooms: Room.List
|
|
}
|
|
});
|
|
|
|
Dashboard.View = Backbone.View.extend({
|
|
el: $('#content'),
|
|
initialize: function () {
|
|
// load the data -- dummy -- struts/node backend
|
|
this.rooms = new Room.List(dataModel.rooms);
|
|
},
|
|
render: function () {
|
|
this.$el.html('');
|
|
_.each(this.rooms.models, function (room) {
|
|
this.renderRoom(room);
|
|
}, this);
|
|
return this;
|
|
},
|
|
renderRoom: function (room) {
|
|
var roomView = new Room.View({
|
|
model: room
|
|
});
|
|
this.$el.append(roomView.render().el);
|
|
},
|
|
renderRoomWithId: function (roomId) {
|
|
this.$el.html('');
|
|
_.each(this.rooms.models, function (room) {
|
|
if (room.get('roomId') == roomId) {
|
|
this.renderRoom(room);
|
|
}
|
|
}, this);
|
|
}
|
|
});
|
|
|
|
})(app.module("dashboard"));
|
|
|
|
|
|
|