forked from bountysource/scope.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
76 lines (57 loc) · 1.25 KB
/
README
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
scope.js -- A client-side view-controller framework for JavaScript
DOM Element Generation:
with (scope()) {
document.body.appendChild(
div(
h1('Hello World!'),
p('Why hello there!')
)
);
}
DOM Templates:
with (scope()) {
define('hello_world', function(content) {
return div(
h1('Hello World!'),
p(content)
);
});
render(hello_world('Why hello there!'));
}
DOM Events:
with (scope()) {
define('handle_click', function(event) {
console.log(event);
});
define('hello_world', function(content) {
return div({ onClick: handle_click },
h1('Hello World!'),
p(content)
);
});
document.body.appendChild(
hello_world('Why hello there!')
);
}
Client-side Hash Routing:
with (scope()) {
route('#', function() {
render(hello_world("This is a test"));
});
}
Form processing:
with (scope()) {
define('process_form', function(data) {
console.log(data);
});
route('#', function() {
render(
form({ action: process_form },
h1('What's your name?'),
div(text({ name: 'first_name', placeholder: 'First Name' }), text({ name: 'last_name', placeholder: 'Last Name' })),
checkbox({ name: 'special' }), 'Are you special?',
button('Go!')
)
);
});
}