I am currently working through this Bootstrap 3 tutorial at TutorialRepublic: http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-dropdowns.php
On that page there are among others two ways to create a dropdown menu:
- using data attributes
- using JavaScript
Markup for way 1:
<div class="bs-example">
<div class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
</ul>
</div>
</div>
Markup for way 2:
<script type="text/javascript">
$(document).ready(function(){
$(".dropdown-toggle").dropdown();
});
</script>
<div class="bs-example">
<div class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
</ul>
</div>
</div>
Then the tutorial says:
The data-toggle="dropdown" is still required for the dropdown's trigger element regardless of whether you call the dropdown via JavaScript or data-api.
So my question is: What is the point in using way 2 if one still needs to specify the data attributes?