-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.htm
106 lines (100 loc) · 2.72 KB
/
index.htm
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery Cascade-Select Plugin Demo</title>
<style>
.demo {
min-height: 200px;
margin: 20px 10px;
}
.demo select {
padding: 0 10px;
height: 30px;
}
</style>
<script src="https://apps.bdimg.com/libs/jquery/1.4.1/jquery.min.js"></script>
<script src="./jquery.cascadeSelect.min.js"></script>
</head>
<body>
<div class="demo">
<p>jQuery Cascade-Select Plugin (from left to right)</p>
<select id="list1"></select><=><select id="list2"></select><=><select id="list3"></select>
</div>
<script>
var list1 = {
"": [
{ id: 1, label: "label1" },
{ id: 2, label: "label2" }
]
};
var list2 = {
"1": [
{ id: 11, label: "label1-1" },
{ id: 12, label: "label1-2" }
],
"2": [
{ id: 21, label: "label2-1" },
{ id: 22, label: "label2-2" }
]
};
var list3 = {
"11": [
{ id: 111, label: "label1-1-1" },
{ id: 112, label: "label1-1-2" }
],
"12": [
{ id: 121, label: "label1-2-1" },
{ id: 122, label: "label1-2-2" }
],
"21": [
{ id: 211, label: "label2-1-1" },
{ id: 212, label: "label2-1-2" }
],
"22": [
{ id: 221, label: "label2-2-1" },
{ id: 222, label: "label2-2-2" }
]
};
$(function() {
var cascadeSelectConfigA = {
upperTierGetter: function() {
return "";
},
dataSource: list1
};
var cascadeSelectConfigB = {
upperTierGetter: function() {
return $("#list1").val();
},
dataSource: list2
};
var cascadeSelectConfigC = {
upperTierGetter: function() {
return $("#list2").val();
},
dataSource: list3
};
$("#list1")
.cascadeSelect(cascadeSelectConfigA)
.bind("cascadeSelectChange", function() {
console.log("List1 fire the change.");
// Update next tier
$("#list2").trigger("update");
});
$("#list2")
.cascadeSelect(cascadeSelectConfigB)
.bind("cascadeSelectChange", function() {
console.log("List2 fire the change.");
// Update next tier
$("#list3").trigger("update");
});
$("#list3")
.cascadeSelect(cascadeSelectConfigC)
.bind("cascadeSelectChange", function() {
console.log("List3 fire the change.");
});
});
</script>
</body>
</html>