forked from DubFriend/jquery.repeater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
187 lines (148 loc) · 6.4 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!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>
<h2>Repeater</h2>
<form action="echo.php" class="repeater" enctype="multipart/form-data">
<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" value="2018-05-01"/>
<input type="url" name="url-input" value="https://exemple.com/a"/>
<input type="color" name="color-input" value="#aaaaaa"/>
<input type="datetime-local" name="datetime-local-input" value="2018-05-12T19:30"/>
<input type="month" name="month-input" value="2018-05"/>
<input type="number" name="number-input" value="42"/>
<input type="search" name="search-input" value="A"/>
<input type="tel" name="tel-input" value="1112223333"/>
<input type="time" name="time-input" value="13:30"/>
<input type="week" name="week-input" value="2018-W26"/>
<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" value="2019-05-01"/>
<input type="url" name="url-input" value="https://exemple.com/b"/>
<input type="color" name="color-input" value="#bbbbbb"/>
<input type="datetime-local" name="datetime-local-input" value="2019-05-12T19:30"/>
<input type="month" name="month-input" value="2019-05"/>
<input type="number" name="number-input" value="43"/>
<input type="search" name="search-input" value="B"/>
<input type="tel" name="tel-input" value="4442223333"/>
<input type="time" name="time-input" value="14:30"/>
<input type="week" name="week-input" value="2019-W26"/>
<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>
<h2>Nested</h2>
<form action="echo.php" class="outer-repeater">
<div data-repeater-list="outer-group" class="outer">
<div data-repeater-item class="outer">
<input type="text" name="text-input" value="A" class="outer"/>
<input data-repeater-delete type="button" value="Delete" class="outer"/>
<div class="inner-repeater">
<div data-repeater-list="inner-group" class="inner">
<div data-repeater-item class="inner">
<input type="text" name="inner-text-input" value="B" class="inner"/>
<input data-repeater-delete type="button" value="Delete" class="inner"/>
</div>
</div>
<input data-repeater-create type="button" value="Add" class="inner"/>
</div>
</div>
</div>
<input data-repeater-create type="button" value="Add" class="outer"/>
</form>
<script src="jquery-1.11.1.js"></script>
<script src="jquery.repeater.js"></script>
<script>
$(document).ready(function () {
'use strict';
$('.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) {
}
});
window.outerRepeater = $('.outer-repeater').repeater({
isFirstItemUndeletable: true,
defaultValues: { 'text-input': 'outer-default' },
show: function () {
console.log('outer show');
$(this).slideDown();
},
hide: function (deleteElement) {
console.log('outer delete');
$(this).slideUp(deleteElement);
},
repeaters: [{
isFirstItemUndeletable: true,
selector: '.inner-repeater',
defaultValues: { 'inner-text-input': 'inner-default' },
show: function () {
console.log('inner show');
$(this).slideDown();
},
hide: function (deleteElement) {
console.log('inner delete');
$(this).slideUp(deleteElement);
}
}]
});
});
</script>
</body>
</html>