diff options
| author | Chris Rebert <[email protected]> | 2014-10-22 18:57:43 -0700 |
|---|---|---|
| committer | Chris Rebert <[email protected]> | 2014-10-22 18:57:43 -0700 |
| commit | 57e4b587828e79962dabe97e9e8ce3c231d7a820 (patch) | |
| tree | 92b7ccb5d39b9a635e1832ff45b8c6501d6cf26f | |
| parent | 5c18722453d112c3a22c2e0fa2150c33e8bc7807 (diff) | |
| parent | b421dc9490239809905d4c544bba4c48af096e22 (diff) | |
| download | bootstrap-57e4b587828e79962dabe97e9e8ce3c231d7a820.tar.xz bootstrap-57e4b587828e79962dabe97e9e8ce3c231d7a820.zip | |
Merge pull request #14859 from twbs/fix-14853
Clarify order of tabs events
| -rw-r--r-- | docs/_includes/js/tabs.html | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/docs/_includes/js/tabs.html b/docs/_includes/js/tabs.html index 570e21e20..f520e0f96 100644 --- a/docs/_includes/js/tabs.html +++ b/docs/_includes/js/tabs.html @@ -115,6 +115,14 @@ $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed) {% endhighlight %} <h3>Events</h3> + <p>When showing a new tab, the events fire in the following order:</p> + <ol> + <li><code>hide.bs.tab</code> (on the current active tab)</li> + <li><code>show.bs.tab</code> (on the to-be-shown tab)</li> + <li><code>hidden.bs.tab</code> (on the previous active tab, the same one as for the <code>hide.bs.tab</code> event)</li> + <li><code>shown.bs.tab</code> (on the newly-active just-shown tab, the same one as for the <code>show.bs.tab</code> event)</li> + </ol> + <p>If no tab was already active, then the <code>hide.bs.tab</code> and <code>hidden.bs.tab</code> events will not be fired.</p> <div class="table-responsive"> <table class="table table-bordered table-striped"> <thead> @@ -134,19 +142,19 @@ $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed) </tr> <tr> <td>hide.bs.tab</td> - <td>This event fires immediately when a new tab is to be shown and before the <code>show.bs.tab</code> event. Use <code>event.relatedTarget</code> to target the new tab.</td> + <td>This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use <code>event.target</code> and <code>event.relatedTarget</code> to target the current active tab and the new soon-to-be-active tab, respectively.</td> </tr> <tr> <td>hidden.bs.tab</td> - <td>This event fires after a new tab is shown and before the <code>shown.bs.tab</code> event. Use <code>event.relatedTarget</code> to target the new tab.</td> + <td>This event fires after a new tab is shown (and thus the previous active tab is hidden). Use <code>event.target</code> and <code>event.relatedTarget</code> to target the previous active tab and the new active tab, respectively.</td> </tr> </tbody> </table> </div><!-- /.table-responsive --> {% highlight js %} $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { - e.target // activated tab - e.relatedTarget // previous tab + e.target // newly activated tab + e.relatedTarget // previous active tab }) {% endhighlight %} </div> |
