|
15 | 15 | <meta name="description" content="Bootstrap Switch Button is a bootstrap plugin that converts checkboxes into responsive switch buttons.">
|
16 | 16 | <meta name="keywords" content="bootstrap, switch, button, bootstrap-checkbox, bootstrap-switch, bootstrap-switch-button, bootstrap-toggle">
|
17 | 17 | <meta name="author" content="https://github.com/gitbrent">
|
18 |
| - <meta name="version" content="20200215"> |
| 18 | + <meta name="version" content="20200216"> |
19 | 19 | <meta name="robots" content="index, follow">
|
20 | 20 | <meta name="revisit-after" content="1 month">
|
21 | 21 | <title>Bootstrap Switch Button</title>
|
@@ -470,6 +470,33 @@ <h3 class="text-secondary mt-4">Event Propagation</h3>
|
470 | 470 | })
|
471 | 471 | </script>
|
472 | 472 | </div>
|
| 473 | + <h3 class="text-secondary mt-4">Stopping Event Propagation</h3> |
| 474 | + <p> |
| 475 | + Passing <code>true</code> to the on/off methods will enable the silent option to prevent the control from propagating the change event in |
| 476 | + cases where you want to update the controls on/off state, but do not want to fire the onChange event. |
| 477 | + </p> |
| 478 | + <div class="example"> |
| 479 | + <input id="toggle-silent" type="checkbox" data-toggle="switchbutton" onchange="$('#chgConsole').text(new Date().toISOString()+' ... change event fired!')"> |
| 480 | + <button class="btn btn-success" onclick="toggleApiOnSilent()" >On by API (silent)</button> |
| 481 | + <button class="btn btn-success" onclick="toggleApiOffSilent()">Off by API (silent)</button> |
| 482 | + <button class="btn btn-warning" onclick="toggleApiOnNotSilent()">On by API (not silent)</button> |
| 483 | + <button class="btn btn-warning" onclick="toggleApiOffNotSilent()">On by API (not silent)</button> |
| 484 | + <script> |
| 485 | + function toggleApiOnSilent() { |
| 486 | + document.getElementById('toggle-silent').switchButton('on', true); |
| 487 | + } |
| 488 | + function toggleApiOffSilent() { |
| 489 | + document.getElementById('toggle-silent').switchButton('off', true); |
| 490 | + } |
| 491 | + function toggleApiOnNotSilent() { |
| 492 | + document.getElementById('toggle-silent').switchButton('on'); |
| 493 | + } |
| 494 | + function toggleApiOffNotSilent() { |
| 495 | + document.getElementById('toggle-silent').switchButton('off'); |
| 496 | + } |
| 497 | + </script> |
| 498 | + <pre class="mb-0"><code id="chgConsole" class="text-info"></code></pre> |
| 499 | + </div> |
473 | 500 |
|
474 | 501 | <h3 class="text-secondary mt-4">API Input</h3>
|
475 | 502 | <p>This also means that using the API or Input to trigger events will work both ways.</p>
|
|
0 commit comments