/
index.html
125 lines (105 loc) · 3.9 KB
/
index.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Repeater</title>
<title>jquery.repeater</title>
<style>
html, body {
font-family: Helvetica, Arial, sans-serif;
color: rgb(80, 80, 80);
}
</style>
</head>
<body>
<h1>Repeater</h1>
<form action="echo.php" class="repeater">
<div data-repeater-list="group-a">
<div data-repeater-item>
<input name="untyped-input" value="A"/>
<input type="text" name="text-input" value="A"/>
<input type="date" name="date-input"/>
<textarea name="textarea-input">A</textarea>
<input type="radio" name="radio-input" value="A" checked/>
<input type="radio" name="radio-input" value="B"/>
<input type="checkbox" name="checkbox-input" value="A" checked/>
<input type="checkbox" name="checkbox-input" value="B"/>
<select name="select-input">
<option value="A" selected>A</option>
<option value="B">B</option>
</select>
<select name="multiple-select-input" multiple>
<option value="A" selected>A</option>
<option value="B" selected>B</option>
</select>
<input data-repeater-delete type="button" value="Delete"/>
</div>
<div data-repeater-item>
<input name="untyped-input" value="A"/>
<input type="text" name="text-input" value="B"/>
<input type="date" name="date-input"/>
<textarea name="textarea-input">B</textarea>
<input type="radio" name="radio-input" value="A" />
<input type="radio" name="radio-input" value="B" checked/>
<input type="checkbox" name="checkbox-input" value="A"/>
<input type="checkbox" name="checkbox-input" value="B" checked/>
<select name="select-input">
<option value="A">A</option>
<option value="B" selected>B</option>
</select>
<select name="multiple-select-input" multiple>
<option value="A" selected>A</option>
<option value="B" selected>B</option>
</select>
<input data-repeater-delete type="button" value="Delete"/>
</div>
</div>
<input data-repeater-create type="button" value="Add"/>
</form>
<script src="jquery-1.11.1.js"></script>
<script src="jquery.repeater.js"></script>
<script>
$(document).ready(function () {
'use strict';
// $('.repeater').repeater(function () {
// return {
// defaultValues: {
// 'textarea-input': 'foo',
// 'text-input': 'bar',
// 'select-input': 'B',
// 'checkbox-input': ['A', 'B'],
// 'radio-input': 'B'
// },
// show: function () {
// $(this).slideDown();
// },
// hide: function (deleteElement) {
// if(confirm('Are you sure you want to delete this element?')) {
// $(this).slideUp(deleteElement);
// }
// }
// };
// });
$('.repeater').repeater({
defaultValues: {
'textarea-input': 'foo',
'text-input': 'bar',
'select-input': 'B',
'checkbox-input': ['A', 'B'],
'radio-input': 'B'
},
show: function () {
$(this).slideDown();
},
hide: function (deleteElement) {
if(confirm('Are you sure you want to delete this element?')) {
$(this).slideUp(deleteElement);
}
},
ready: function (setIndexes) {
}
});
});
</script>
</body>
</html>