-
Notifications
You must be signed in to change notification settings - Fork 18
/
complex-sample.html
72 lines (69 loc) · 2.08 KB
/
complex-sample.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
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>
<script src="src/jquery.jsForm.controls.js"></script>
<script src="src/jquery.jsForm.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
<script>
$(function(){
// some json data
var jsonData = {
name: "TestName", // standard inputs
props: {
active: true, // checkbox
groups: [{
name: "Base",
priority: 0,
tasks: [{ id:0, name: "base task1", priority: 1}, {id:1,name: "base task0", priority: 0}, {id:2,name: "base task2", priority: 2}]
},
{
name: "Important",
priority: 2,
tasks: [{id:0, name: "imp task1", priority: 1}, {id:1,name: "imp task0", priority: 0}]
},
{
name: "Other",
priority: 1,
tasks: [{id:0, name: "other", priority: 1}]
}]
},
state: "VISIBLE" // selects (enums)
};
// initialize the form, prefix is optional and defaults to data
$("#details").jsForm({
data:jsonData
});
$("#show").click(function() {
// show the json data
alert(JSON.stringify($("#details").jsForm("get"), null, " "));
});
});
</script>
</head>
<body>
<h1>Multi level array testform</h1>
<div id="details">
Name: <input name="data.name"/><br/>
<input type="checkbox" name="data.props.active"/> active<br/>
<select name="data.state">
<option value="VISIBLE">visible</option>
<option value="IMPORTANT">important</option>
<option value="HIDDEN">hidden</option>
</select>
<div class="collection sort" data-field="data.props.groups" data-sort="priority">
<fieldset>
<legend>Group: <span class="field">groups.name</span></legend>
<ul class="collection sort reorder" data-field="groups.tasks" data-sort="priority">
<li><input name="tasks.name"/></li>
</ul>
<button class="sortUp">up</button> <button class="sortDown">down</button>
</fieldset>
</div>
</div>
<button id="show">Show Object</button>
</body>
</html>