aboutsummaryrefslogtreecommitdiff
path: root/docs/javascript.html
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-03-06 21:32:52 -0800
committerMark Otto <[email protected]>2014-03-06 21:32:52 -0800
commitc8614c0f15f0ce78426c6403e57aff22c3ce2beb (patch)
tree673d1a347374a8bf53a127c050dbc57762af3782 /docs/javascript.html
parentd1a7271ea1272e0f9775d49e6a84ee49819e0094 (diff)
parentfab10b643eb1a2038fb31305f0b038b7a9a8554d (diff)
downloadbootstrap-c8614c0f15f0ce78426c6403e57aff22c3ce2beb.tar.xz
bootstrap-c8614c0f15f0ce78426c6403e57aff22c3ce2beb.zip
Merge branch 'master' into pr/12490
Conflicts: less/list-group.less
Diffstat (limited to 'docs/javascript.html')
-rw-r--r--docs/javascript.html65
1 files changed, 41 insertions, 24 deletions
diff --git a/docs/javascript.html b/docs/javascript.html
index 9f57d0725..bf5944fcb 100644
--- a/docs/javascript.html
+++ b/docs/javascript.html
@@ -15,8 +15,13 @@ lead: "Bring Bootstrap's components to life with over a dozen custom jQuery plug
<p>Plugins can be included individually (using Bootstrap's individual <code>*.js</code> files), or all at once (using <code>bootstrap.js</code> or the minified <code>bootstrap.min.js</code>).</p>
<div class="bs-callout bs-callout-danger">
- <h4>Do not attempt to include both.</h4>
- <p>Both <code>bootstrap.js</code> and <code>bootstrap.min.js</code> contain all plugins in a single file.</p>
+ <h4>Using the compiled JavaScript</h4>
+ <p>Both <code>bootstrap.js</code> and <code>bootstrap.min.js</code> contain all plugins in a single file. Include only one.</p>
+ </div>
+
+ <div class="bs-callout bs-callout-danger">
+ <h4>Component data attributes</h4>
+ <p>Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a modal. To accomplish this, use a wrapping element.</p>
</div>
<div class="bs-callout bs-callout-danger">
@@ -60,7 +65,7 @@ $.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the Boot
{% endhighlight %}
<h3 id="js-events">Events</h3>
- <p>Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. <code>show</code>) is triggered at the start of an event, and its past participle form (ex. <code>shown</code>) is trigger on the completion of an action.</p>
+ <p>Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. <code>show</code>) is triggered at the start of an event, and its past participle form (ex. <code>shown</code>) is triggered on the completion of an action.</p>
<p>As of 3.0.0, all Bootstrap events are namespaced.</p>
<p>All infinitive events provide <code>preventDefault</code> functionality. This provides the ability to stop the execution of an action before it starts.</p>
{% highlight js %}
@@ -236,14 +241,14 @@ $('#myModal').on('show.bs.modal', function (e) {
<h2 id="modals-sizes">Optional sizes</h2>
<p>Modals have two optional sizes, available via modifier classes to be placed on a <code>.modal-dialog</code>.</p>
<div class="bs-example">
- <button class="btn btn-primary" data-toggle="modal" data-target=".bs-modal-lg">Large modal</button>
- <button class="btn btn-primary" data-toggle="modal" data-target=".bs-modal-sm">Small modal</button>
+ <button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>
+ <button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>
</div>
{% highlight html %}
<!-- Large modal -->
-<button class="btn btn-primary" data-toggle="modal" data-target=".bs-modal-lg">Large modal</button>
+<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>
-<div class="modal fade bs-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
+<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
...
@@ -252,9 +257,9 @@ $('#myModal').on('show.bs.modal', function (e) {
</div>
<!-- Small modal -->
-<button class="btn btn-primary" data-toggle="modal" data-target=".bs-modal-sm">Small modal</button>
+<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>
-<div class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
+<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
...
@@ -264,7 +269,7 @@ $('#myModal').on('show.bs.modal', function (e) {
{% endhighlight %}
<!-- Modal content for the above example -->
- <div class="modal fade bs-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
+ <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
@@ -278,7 +283,7 @@ $('#myModal').on('show.bs.modal', function (e) {
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
- <div class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
+ <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
@@ -293,6 +298,13 @@ $('#myModal').on('show.bs.modal', function (e) {
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
+ <h2 id="modals-remove-animation">Remove animation</h2>
+ <p>For modals that simply appear rather than fade in to view, remove the <code>.fade</code> class from your modal markup.</p>
+{% highlight html %}
+<div class="modal" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
+ ...
+</div>
+{% endhighlight %}
<h2 id="modals-usage">Usage</h2>
<p>The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds <code>.modal-open</code> to the <code>&lt;body&gt;</code> to override default scrolling behavior and generates a <code>.modal-backdrop</code> to provide a click area for dismissing shown modals when clicking outside the modal.</p>
@@ -342,7 +354,7 @@ $('#myModal').on('show.bs.modal', function (e) {
<td>remote</td>
<td>path</td>
<td>false</td>
- <td><p>If a remote URL is provided, <strong>content will be loaded one time</strong> via jQuery's <code>load</code> method and injected into the root of the modal element. If you're using the data-api, you may alternatively use the <code>href</code> attribute to specify the remote source. An example of this is shown below:</p>
+ <td><p>If a remote URL is provided, <strong>content will be loaded one time</strong> via jQuery's <code>load</code> method and injected into the <code>.modal-content</code> div. If you're using the data-api, you may alternatively use the <code>href</code> attribute to specify the remote source. An example of this is shown below:</p>
{% highlight html %}
<a data-toggle="modal" href="remote.html" data-target="#modal">Click me</a>
{% endhighlight %}
@@ -430,7 +442,7 @@ $('#myModal').on('hidden.bs.modal', function (e) {
<nav id="navbar-example" class="navbar navbar-default navbar-static" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
- <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-js-navbar-collapse">
+ <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-example-js-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@@ -438,7 +450,7 @@ $('#myModal').on('hidden.bs.modal', function (e) {
</button>
<a class="navbar-brand" href="#">Project Name</a>
</div>
- <div class="collapse navbar-collapse bs-js-navbar-collapse">
+ <div class="collapse navbar-collapse bs-example-js-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a id="drop1" href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
@@ -548,6 +560,10 @@ $('#myModal').on('hidden.bs.modal', function (e) {
{% highlight js %}
$('.dropdown-toggle').dropdown()
{% endhighlight %}
+ <div class="bs-callout bs-callout-info">
+ <h4><code>data-toggle="dropdown"</code> still required</h4>
+ <p>Regardless of whether you call your dropdown via JavaScript or instead use the data-api, <code>data-toggle="dropdown"</code> is always required to be present on the dropdown's trigger element.</p>
+ </div>
<h3>Options</h3>
<p><em>None</em></p>
@@ -557,6 +573,7 @@ $('.dropdown-toggle').dropdown()
<p>Toggles the dropdown menu of a given navbar or tabbed navigation.</p>
<h3>Events</h3>
+ <p>All dropdown events are fired at the <code>.dropdown-menu</code>'s parent element.</p>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
@@ -604,7 +621,7 @@ $('#myDropdown').on('show.bs.dropdown', function () {
<nav id="navbar-example2" class="navbar navbar-default navbar-static" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
- <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-js-navbar-scrollspy">
+ <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-example-js-navbar-scrollspy">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@@ -612,7 +629,7 @@ $('#myDropdown').on('show.bs.dropdown', function () {
</button>
<a class="navbar-brand" href="#">Project Name</a>
</div>
- <div class="collapse navbar-collapse bs-js-navbar-scrollspy">
+ <div class="collapse navbar-collapse bs-example-js-navbar-scrollspy">
<ul class="nav navbar-nav">
<li><a href="#fat">@fat</a></li>
<li><a href="#mdo">@mdo</a></li>
@@ -1434,10 +1451,10 @@ $('#my-alert').bind('closed.bs.alert', function () {
</button>
<script>
$('#loading-example-btn').click(function () {
- var btn = $(this);
- btn.button('loading');
+ var btn = $(this)
+ btn.button('loading')
$.ajax(...).always(function () {
- btn.button('reset');
+ btn.button('reset')
});
});
</script>
@@ -1542,10 +1559,10 @@ $('.btn').button()
<button id="loading-example-btn" type="button" class="btn btn-primary" data-loading-text="loading stuff...">...</button>
<script>
$('#loading-example-btn').click(function () {
- var btn = $(this);
- btn.button('loading');
+ var btn = $(this)
+ btn.button('loading')
$.ajax(...).always(function () {
- btn.button('reset');
+ btn.button('reset')
});
});
</script>
@@ -2063,11 +2080,11 @@ $('#myCarousel').on('slide.bs.carousel', function () {
<h3>Via JavaScript</h3>
<p>Call the affix plugin via JavaScript:</p>
{% highlight js %}
- $('#myAffix').affix({
+ $('#my-affix').affix({
offset: {
top: 100
, bottom: function () {
- return (this.bottom = $('.bs-footer').outerHeight(true))
+ return (this.bottom = $('.footer').outerHeight(true))
}
}
})