-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontroller.js
More file actions
39 lines (35 loc) · 1.08 KB
/
controller.js
File metadata and controls
39 lines (35 loc) · 1.08 KB
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
34
35
36
37
38
39
/**
* Created by 宇乔 on 13-11-25.
*/
jex.define('controller', {
type: 'ctl',
view: '',
alias: 'controller',
controls: [],
init: function () {
var that = this;
var controls = this.controls;
jex.ctl[this.alias] = {
getView: function () {
return jex.instancesManager.getbyAlias(that.view)[0];
}
}
jex.each(controls, function (item, index) {
var type = item.type,
fn = item.handler,
pageId = jex.instancesManager.getbyAlias(that.view)[0].element.id,
selector = '#' + pageId + ' ' + item.selector;
var handler;
if (jex.isString(fn)) {
if (that[fn]) {
fn = that[fn];
}
}
if (jex.isFunction(fn)) {
jex.EventManager.subscribe(type, fn, selector,jex.ctl[that.alias].getView());
} else {
jex.error.show('Event Hansler must be funcion !but this is a ' + typeof fn);
}
});
}
})