Skip to content

Commit 6291dc9

Browse files
committed
Fix wenzhixin#61: the hidden table reset header bug.
1 parent bd779c2 commit 6291dc9

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

docs/examples.html

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ <h1>Examples</h1>
6565
<p>The examples of bootstrap table.</p>
6666
</div>
6767
</div>
68+
6869
<div class="container">
6970
<div class="row">
7071
<div class="col-md-3 span3">
@@ -129,7 +130,12 @@ <h2>Use API:</h2>
129130
</ul>
130131
</div>
131132
<div class="page-header">
132-
<h1 id="basic-table">Basic Table</h1>
133+
<h1 id="basic-table">
134+
Basic Table
135+
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal">
136+
Launch modal
137+
</button>
138+
</h1>
133139
</div>
134140
<div class="bs-example">
135141
<table data-toggle="table" data-url="data1.json" data-height="299">
@@ -143,6 +149,33 @@ <h1 id="basic-table">Basic Table</h1>
143149
</table>
144150
</div>
145151
<div class="highlight"><pre><code class="language-html"></code></pre></div>
152+
153+
<!-- Modal -->
154+
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
155+
<div class="modal-dialog">
156+
<div class="modal-content">
157+
<div class="modal-header">
158+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
159+
<h4 class="modal-title" id="myModalLabel">Basic Table</h4>
160+
</div>
161+
<div class="modal-body">
162+
<table data-toggle="table" data-url="data1.json" data-height="299">
163+
<thead>
164+
<tr>
165+
<th data-field="id">Item ID</th>
166+
<th data-field="name">Item Name</th>
167+
<th data-field="price">Item Price</th>
168+
</tr>
169+
</thead>
170+
</table>
171+
</div>
172+
<div class="modal-footer">
173+
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
174+
<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>
175+
</div>
176+
</div>
177+
</div>
178+
</div>
146179
</div>
147180

148181
<div>

src/bootstrap-table.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
this.options = options;
5252
this.$el = $(el);
5353
this.$el_ = this.$el.clone();
54+
this.timeoutId_ = 0;
5455

5556
this.init();
5657
};
@@ -904,6 +905,13 @@
904905
BootstrapTable.prototype.resetHeader = function () {
905906
var that = this;
906907

908+
// fix #61: the hidden table reset header bug.
909+
if (this.$el.is(':hidden')) {
910+
clearTimeout(this.timeoutId_); // doesn't matter if it's 0
911+
this.timeoutId_ = setTimeout($.proxy(this.resetHeader, this), 100); // 100ms
912+
return;
913+
}
914+
907915
this.$header_ = this.$header.clone(true);
908916
this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
909917
this.$el.css('margin-top', -this.$header.height());

0 commit comments

Comments
 (0)