blob: 0bcf4c1bfaa2ba0b2faf291c6932ce509b767aa5 (
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
31
32
33
|
// Use this as a quick template for future modules
define([
'jquery',
'underscore',
'backbone',
'events'
], function($, _, Backbone, Events){
var views = {};
var create = function (context, name, View, options) {
// View clean up isn't actually implemented yet but will simply call .clean, .remove and .unbind
if(typeof views[name] !== 'undefined') {
views[name].undelegateEvents();
if(typeof views[name].clean === 'function') {
views[name].clean();
}
}
var view = new View(options);
views[name] = view;
if(typeof context.children === 'undefined'){
context.children = {};
context.children[name] = view;
} else {
context.children[name] = view;
}
Events.trigger('viewCreated');
return view;
}
return {
create: create
};
});
|