forked from xiamaoxialeyan/My.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
56 lines (49 loc) · 1.94 KB
/
test.html
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
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="My.js"></script>
</head>
<body>
<div><a href="">11111</a></div>
<div><a href="">22222</a></div>
<div id="formbox"></div>
<canvas id="mycanvas" style="border:1px solid #c3c3c3;">哈哈哈哈哈</canvas>
</body>
<script type="text/javascript">
var home = new M.Model('', {
name: 'luoying',
wife: 'liyanyan',
son: 'luolinan'
});
var HomeView = M.View.extend({
tpl: '<form><div><input name="name" value="{{name}}"></div><div><input name="wife" value="{{wife}}"></div><div><input name="son" value="{{son}}"></div><div><input type="submit"></div></form>',
events: {
'submit form': function(evt) {
evt.preventDefault();
},
'change? input': function(evt, view) {
view.provider.set(this.name, this.value);
}
},
initialize: function() {
this.provider.on('change', function() {
debugger
});
}
});
var hv = new HomeView('#formbox', home);
M.canvas.wrap('#mycanvas').attr({
'fillStyle': '#FF0000'
}).beginPath().arc(70, 18, 15, 0, Math.PI * 2, true).closePath().fill().unwrap();
/*var s='<div [[repeat]]><div data-id="{{id}}"><label>{{name}}</label></div></div>';
console.log(M.template(s,[{id:1,name:'luoying'},{id:2,name:'liyanyan'},{id:3,name:'luolinan'}]));*/
// var s='<li [[repeat]]><a data-id="{{id}}"><label>{{name}}</label></a></li>';
// console.log(M.template(s,[{id:1,name:'luoying'},{id:2,name:'liyanyan'},{id:3,name:'luolinan'}]));
var s=['<ul class="component-emoticon-stack" [[repeat|4]]>',
'<li[[repeat]]><img data-src="{{src}}"></li>',
'</ul>'
].join('');
console.log(M.template(s,[{src:'xxx'},{src:'yyy'},{src:'zzz'},{src:'www'}]));
</script>
</html>