aboutsummaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2019-08-04 11:55:37 +0200
committerJohann-S <[email protected]>2019-08-04 13:22:47 +0200
commit8468f4a37e4bdbbef7a8bcc8207c8cef4999ea5d (patch)
treeb000308298881540f0fc516e7770855893cab894 /site
parent2be5f03bfc972df4f837826feecd33a07a83dc7f (diff)
downloadbootstrap-8468f4a37e4bdbbef7a8bcc8207c8cef4999ea5d.tar.xz
bootstrap-8468f4a37e4bdbbef7a8bcc8207c8cef4999ea5d.zip
remove jquery references from list group
Diffstat (limited to 'site')
-rw-r--r--site/content/docs/4.3/components/list-group.md52
1 files changed, 38 insertions, 14 deletions
diff --git a/site/content/docs/4.3/components/list-group.md b/site/content/docs/4.3/components/list-group.md
index 032ef37f5..21bab14d7 100644
--- a/site/content/docs/4.3/components/list-group.md
+++ b/site/content/docs/4.3/components/list-group.md
@@ -281,19 +281,25 @@ You can activate a list group navigation without writing any JavaScript by simpl
Enable tabbable list item via JavaScript (each list item needs to be activated individually):
{{< highlight js >}}
-$('#myList a').on('click', function (e) {
- e.preventDefault()
- $(this).tab('show')
+var triggerTabList = [].slice.call(document.querySelectorAll('#myTab a'))
+triggerTabList.forEach(function (triggerEl) {
+ var tabTrigger = new bootstrap.Tab(triggerEl)
+
+ triggerEl.addEventListener('click', function (e) {
+ e.preventDefault()
+ tabTrigger.show()
+ })
})
{{< /highlight >}}
You can activate individual list item in several ways:
{{< highlight js >}}
-$('#myList a[href="#profile"]').tab('show') // Select tab by name
-$('#myList a:first-child').tab('show') // Select first tab
-$('#myList a:last-child').tab('show') // Select last tab
-$('#myList a:nth-child(3)').tab('show') // Select third tab
+var triggerEl = document.querySelector('#myTab a[href="#profile"]')
+bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
+
+var triggerFirstTabEl = document.querySelector('#myTab li:first-child a')
+bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
{{< /highlight >}}
### Fade effect
@@ -311,7 +317,7 @@ To make tabs panel fade in, add `.fade` to each `.tab-pane`. The first tab pane
### Methods
-#### $().tab
+#### constructor
Activates a list item element and content container. Tab should have either a `data-target` or an `href` targeting a container node in the DOM.
@@ -331,18 +337,35 @@ Activates a list item element and content container. Tab should have either a `d
</div>
<script>
- $(function () {
- $('#myList a:last-child').tab('show')
- })
+ var firstTabEl = document.querySelector('#myTab a:last-child')
+ var firstTab = new bootstrap.Tab(firstTabEl)
+
+ firstTab.show()
</script>
{{< /highlight >}}
-#### .tab('show')
+#### show
Selects the given list item and shows its associated pane. Any other list item that was previously selected becomes unselected and its associated pane is hidden. **Returns to the caller before the tab pane has actually been shown** (for example, before the `shown.bs.tab` event occurs).
{{< highlight js >}}
-$('#someListItem').tab('show')
+ var someListItemEl = document.querySelector('#someListItem')
+ var tab = new bootstrap.Tab(someListItemEl)
+
+ tab.show()
+{{< /highlight >}}
+
+#### dispose
+
+Destroys an element's tab.
+
+#### getInstance
+
+*Static* method which allows you to get the tab instance associated with a DOM element
+
+{{< highlight js >}}
+var triggerEl = document.querySelector('#trigger')
+var tab = bootstrap.Tab.getInstance(triggerEl) // Returns a Bootstrap tab instance
{{< /highlight >}}
### Events
@@ -384,7 +407,8 @@ If no tab was already active, the `hide.bs.tab` and `hidden.bs.tab` events will
</table>
{{< highlight js >}}
-$('a[data-toggle="list"]').on('shown.bs.tab', function (e) {
+var tabEl = document.querySelector('a[data-toggle="list"]')
+tabEl.addEventListener('shown.bs.tab', function (e) {
e.target // newly activated tab
e.relatedTarget // previous active tab
})