-
Notifications
You must be signed in to change notification settings - Fork 117
/
callbacks.html
79 lines (72 loc) · 2.2 KB
/
callbacks.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Static HTML Demo</title>
<style>
#wrapper {
width: 600px;
height: 400px;
margin: 0 auto;
}
</style>
</head>
<body>
<div
id="wrapper"
data-tf-widget="HLjqXS5W"
data-tf-source="localhost"
data-tf-on-ready="onTypeformReady"
data-tf-on-started="onTypeformStarted"
data-tf-on-submit="onTypeformSubmit"
data-tf-on-question-changed="onTypeformQuestionChanged"
data-tf-on-height-changed="onTypeformHeightChanged"
data-tf-on-close="onTypeformClose"
data-tf-on-ending-button-click="onTypeformEndingButtonClick"
></div>
<button
data-tf-popup="HLjqXS5W"
data-tf-source="localhost"
data-tf-on-ready="onTypeformReady"
data-tf-on-started="onTypeformStarted"
data-tf-on-submit="onTypeformSubmit"
data-tf-on-question-changed="onTypeformQuestionChanged"
data-tf-on-close="onTypeformClose"
data-tf-on-ending-button-click="onTypeformEndingButtonClick"
>
open popup
</button>
<script src="./lib/embed.js"></script>
<script>
// customers are often defining callbacks AFTER embedding the form
// https://github.com/Typeform/embed/issues/363
function onTypeformReady(data) {
alert('onReady')
console.log('form ready', data)
}
function onTypeformStarted(data) {
alert('onStarted')
console.log('form started', data)
}
function onTypeformSubmit(data) {
alert('onSubmit')
console.log('form submitted', data)
}
function onTypeformQuestionChanged(data) {
console.log('form question changed', data)
}
function onTypeformHeightChanged(data) {
console.log('form height changed', data)
}
function onTypeformClose(data) {
alert('onClose')
console.log('modal window closed', data)
}
function onTypeformEndingButtonClick(data) {
alert('onEndingButtonClick')
console.log('button on ending screen clicked', data)
}
</script>
</body>
</html>