-
Notifications
You must be signed in to change notification settings - Fork 0
/
event-debind.js
41 lines (33 loc) · 956 Bytes
/
event-debind.js
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
var Gaffa = require('gaffa'),
Set = require('gaffa-set'),
Push = require('gaffa-push'),
Button = require('gaffa-button'),
List = require('gaffa-list'),
gaffa = new Gaffa();
// Register used viewItems with gaffa
gaffa.registerConstructor(Set);
gaffa.registerConstructor(Push);
gaffa.registerConstructor(Button);
gaffa.registerConstructor(List);
var set = new Set();
set.source.binding = '(array "first")';
set.target.binding = '[/values]';
var addValue = new Push();
addValue.source.binding = '(math.random)';
addValue.target.binding = '[/values]';
var button = new Button();
button.text.binding = '[]';
button.actions.mouseup = [set];
button.actions.click = [addValue];
var buttonList = new List();
buttonList.list.template = button;
buttonList.list.binding = '[values]';
// Add the view
gaffa.views.add([
buttonList
]);
gaffa.model.set({
values:['first']
});
// Globalise gaffa for easy debugging.
window.gaffa = gaffa;