-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.html
More file actions
92 lines (81 loc) · 2.96 KB
/
demo.html
File metadata and controls
92 lines (81 loc) · 2.96 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div data-scope="dialog">
<span data-bind="di-name"></span><br /><br />
<label>name: </label><input type="text" data-bind="di-name"><br /><br />
<label>name: </label><input type="text" data-bind="di-name"><br /><br />
<label>role: </label>
<select data-bind="di-role">
<option value='admin'>admin</option>
<option value='user'>user</option>
</select><br /><br />
<label>role: </label>
<select data-bind="di-role">
<option value='admin'>admin</option>
<option value='user'>user</option>
</select><br /><br />
<label>description: </label><textarea data-bind="di-desc"></textarea><br /><br />
<label>description: </label><textarea data-bind="di-desc"></textarea><br /><br />
<label>sex: </label>
<label><input type="radio" name="sex1" data-bind="di-sex" value="male">male</label>
<label><input type="radio" name="sex1" data-bind="di-sex" value="female">female</label><br /><br />
<label>sex: </label>
<label><input type="radio" name="sex2" data-bind="di-sex" value="male">male</label>
<label><input type="radio" name="sex2" data-bind="di-sex" value="female">female</label><br /><br />
<label>remember: </label>
<input type="checkbox" data-bind="di-remember"><br /><br />
<label>remember: </label>
<input type="checkbox" data-bind="di-remember"><br /><br />
</div>
</body>
<script type="text/javascript" src="dataBind.js"></script>
<script type="text/javascript">
var i = {
name: 'Quan',
role: 'user',
desc: 'a programmer',
sex: 'male',
remember: true,
id: ''
};
// var ientity = new Entity(i);
var CustomEntity = Entity.extendBindStrategy({
'span': {
boardcast: function(proxy, key) {
if (proxy[key] === 0 || proxy[key] === '') {
if (proxy[key] === this.innerHTML) {
return;
}
} else if (proxy[key] == this.innerHTML) {
return;
}
this.innerHTML = proxy[key];
}
}
});
ACustomEntity = CustomEntity.extend({
initialize: function(sourceData, option) {
if (option.aaa) {
this.aaa = option.aaa;
}
this.bind(sourceData, option);
},
save: function() {
console.log(this.toPlainObject());
},
update: function() {
console.log('update22');
}
});
var ientity = new ACustomEntity(i, {
scope: 'dialog',
bindCheck: false,
namePrefix: 'di-'
});
ientity.name = 'Quan Li';
</script>
</html>