Cross Reference: /yui3/src/app/tests/manual/controller.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Controller Test</title>
</head>
<body>
<textarea id="log" cols="80" rows="10"></textarea>
<p>
<button id="push">pushState</button>
<a href="http://www.yahoo.com/">Yahoo!</a>
</p>
<script src="http://platypus-lan:3000/build/yui/yui.js"></script>
<script>
document.getElementById('log').value = '';
var Y = YUI({filter: 'raw',}).use('controller', 'node', function (Y) {
var logEl = document.getElementById('log'),
controller = new Y.Controller();
controller.route('/*anything', function (req) {
log('route called, path: ' + req.path);
});
controller.dispatch();
function log(message) {
logEl.value += message + '\n';
}
Y.one('#push').on('click', function () {
controller.save('/' + Y.Lang.now());
});
});
</script>
</body>
</html>