-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
73 lines (64 loc) · 2.2 KB
/
index.html
File metadata and controls
73 lines (64 loc) · 2.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HTML-Multibox</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="multibox.js"></script>
<script>
var obj0 = new Multibox('#data-box0', function (data, source) {
data.id = 23;
$.ajax({
type: 'post',
data: data,
url: 'ajax/box.php',
success: function (response) {
source({ view: response });
}
});
}, function (data, source) {
data.id = 25;
$.ajax({
type: 'post',
data: data,
url: 'ajax/row.php',
success: function (response) {
source({ view: response });
}
});
});
var obj1 = new Multibox('#data-box1', function (data, source) {
source({
view: '<div class="box">[BOX ' + data.box + ' ]<button style="display:none" class="remove-box" onclick="obj1.deleteBox($(this).parent(),1,boxDelete)">REMOVE BOX</button><button class="add-box" onclick="obj1.getBox()">ADD BOX</button><div class="data-row">[BOX ' + data.box + ', ROW ' + data.row + ']<button onclick="obj1.getRow(this,$(this).parent().parent())" class="add-row">ADD ROW</button><button class="remove-row" style="display:none" onclick="obj1.deleteRow($(this).parent(),1,rowDelete)">REMOVE</button></div><br/></div>'
});
}, function (data, source) {
source({
view: '<div class="data-row">[BOX ' + data.box + ', ROW ' + data.row + ']<button onclick="obj1.getRow(this,$(this).parent().parent())" class="add-row">ADD ROW</button><button style="display:none" class="remove-row" onclick="obj1.deleteRow($(this).parent())">REMOVE</button></div>'
});
});
function boxDelete(el, id) {
console.log('callback function boxDelete() called');
$(el).remove();
}
function rowDelete(el, id) {
console.log('callback function rowDelete() called');
$(el).remove();
}
$(document).ready(function () {
obj0.getBox();
obj1.getBox();
});
</script>
</head>
<body>
<div id="data-box0" data-index="0">
<div class="box"></div>
</div>
<hr />
<div id="data-box1" data-index="0">
<div class="box"></div>
</div>
</body>
</html>