Skip to content

Commit 207203d

Browse files
authored
Merge pull request #571 from wenzhixin/feature/fix-table-icons-selector
Fix: use icon-label class to avoid selecting table headers in icons example
2 parents 92c43d8 + 181ab7d commit 207203d

1 file changed

Lines changed: 34 additions & 27 deletions

File tree

options/table-icons.html

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,83 +7,66 @@
77
})
88
</script>
99

10-
<script>
11-
const $table = $('#table')
12-
13-
function mounted () {
14-
$('label input').blur(function () {
15-
const icons = {}
16-
17-
$('label').each(function () {
18-
icons[$(this).find('span').text()] = $(this).find('input').val()
19-
})
20-
$table.bootstrapTable('destroy').bootstrapTable({
21-
icons
22-
})
23-
})
24-
}
25-
</script>
26-
2710
<template>
2811
<div>
29-
<label><span>paginationSwitchDown</span> <input
12+
<label class="icon-label"><span>paginationSwitchDown</span> <input
3013
class="form-control"
3114
type="text"
3215
value="fa-caret-square-down"
3316
></label>
3417
</div>
3518
<div>
36-
<label><span>paginationSwitchUp</span> <input
19+
<label class="icon-label"><span>paginationSwitchUp</span> <input
3720
class="form-control"
3821
type="text"
3922
value="fa-caret-square-up"
4023
></label>
4124
</div>
4225
<div>
43-
<label><span>refresh</span> <input
26+
<label class="icon-label"><span>refresh</span> <input
4427
class="form-control"
4528
type="text"
4629
value="fa-sync"
4730
></label>
4831
</div>
4932
<div>
50-
<label><span>toggleOff</span> <input
33+
<label class="icon-label"><span>toggleOff</span> <input
5134
class="form-control"
5235
type="text"
5336
value="fa-toggle-off"
5437
></label>
5538
</div>
5639
<div>
57-
<label><span>toggleOn</span> <input
40+
<label class="icon-label"><span>toggleOn</span> <input
5841
class="form-control"
5942
type="text"
6043
value="fa-toggle-on"
6144
></label>
6245
</div>
6346
<div>
64-
<label><span>columns</span> <input
47+
<label class="icon-label"><span>columns</span> <input
6548
class="form-control"
6649
type="text"
6750
value="fa-th-list"
6851
></label>
6952
</div>
7053
<div>
71-
<label><span>fullscreen</span> <input
54+
<label class="icon-label"><span>fullscreen</span> <input
7255
class="form-control"
7356
type="text"
7457
value="fa-arrows-alt"
7558
></label>
7659
</div>
7760
<div>
78-
<label><span>detailOpen</span> <input
61+
<label class="icon-label"><span>detailOpen</span> <input
7962
class="form-control"
8063
type="text"
8164
value="fa-plus"
8265
></label>
8366
</div>
8467

8568
<div>
86-
<label><span>detailClose</span> <input
69+
<label class="icon-label"><span>detailClose</span> <input
8770
class="form-control"
8871
type="text"
8972
value="fa-minus"
@@ -92,7 +75,6 @@
9275

9376
<table
9477
id="table"
95-
data-toggle="table"
9678
data-height="460"
9779
data-show-pagination-switch="true"
9880
data-show-refresh="true"
@@ -118,6 +100,31 @@
118100
</table>
119101
</template>
120102

103+
<script>
104+
const $table = $('#table')
105+
106+
function mounted () {
107+
const getIconsOptions = () => {
108+
const icons = {}
109+
110+
$('label.icon-label').each(function () {
111+
icons[$(this).find('span').text()] = $(this).find('input').val()
112+
})
113+
114+
return {
115+
iconsPrefix: 'fa',
116+
icons
117+
}
118+
}
119+
120+
$('label.icon-label input').blur(function () {
121+
$table.bootstrapTable('destroy').bootstrapTable(getIconsOptions())
122+
})
123+
124+
$table.bootstrapTable(getIconsOptions())
125+
}
126+
</script>
127+
121128
<style>
122129
label input {
123130
display: inline-block !important;

0 commit comments

Comments
 (0)