-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
48 lines (44 loc) · 1005 Bytes
/
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
<!DOCTYPE html>
<html>
<head>
<head>
<title>SPA Chapter 1 section 1.2.2</title>
<script type="text/javascript">
var prison = (function(){
var prison_name='Mike',
term = '20 year';
return{
prisoner = prison_name +'---'+term;
};
})();
$('body').append('<div id = "spa-chat-list-box" />');
var $listbox = $("#spa-chat-list-box");
$listbox.css({
position:'absolute', 'z-index':3,
top:50, left:50, width:50, height:50,
border:'2px solid black', background:'#fff'
});
var onListChange = function(event, update_map){
$(this).html(update_map.list_text);
alert('OnListChange run');
};
$.gevent.subscribe(
$listbox, //$listbox这个集合订阅了事件
'spa-listChange', //自定义全局事件
onListChange //订阅函数
);
//调用订阅的事件
$.gevent.publish(
'spa-listChange',
[{list_text: 'the list is here'}]
);
$listbox.remove();
$gevent.publish('spa-listChange',[{}]);
</head>
<body>
<div id="spa">
<div class="spa-slider"></div>
</div>
</body>
</head>
</html>