methods-3.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="description" content="Turn checkboxes and radio buttons in toggle switches.">
  8. <meta name="author" content="Mattia Larentis, Emanuele Marchi and Peter Stein">
  9. <title>Bootstrap Switch · Turn checkboxes and radio buttons in toggle switches</title>
  10. <link href="http://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
  11. <link href="docs/css/bootstrap.min.css" rel="stylesheet">
  12. <link href="docs/css/highlight.css" rel="stylesheet">
  13. <link href="dist/css/bootstrap3/bootstrap-switch.css" rel="stylesheet">
  14. <link href="docs/css/main.css" rel="stylesheet">
  15. <script>
  16. var _gaq = _gaq || [];
  17. _gaq.push(['_setAccount', 'UA-43092768-1']);
  18. _gaq.push(['_trackPageview']);
  19. (function () {
  20. var ga = document.createElement('script');
  21. ga.type = 'text/javascript';
  22. ga.async = true;
  23. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  24. var s = document.getElementsByTagName('script')[0];
  25. s.parentNode.insertBefore(ga, s);
  26. })();
  27. </script>
  28. </head>
  29. <body><a href="https://github.com/nostalgiaz/bootstrap-switch" id="github"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
  30. <header role="banner" class="navbar navbar-default navbar-fixed-top top">
  31. <div class="container">
  32. <div class="navbar-header">
  33. <button type="button" data-toggle="collapse" data-target="#collapse" class="navbar-toggle"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a href="../" class="navbar-brand">Bootstrap Switch <strong>3</strong></a>
  34. </div>
  35. <nav id="collapse" role="navigation" class="collapse navbar-collapse">
  36. <ul class="nav navbar-nav">
  37. <li class="dropdown"><a href="#" data-toggle="dropdown">Download<span class="caret"></span></a>
  38. <ul class="dropdown-menu">
  39. <li><a href="https://github.com/nostalgiaz/bootstrap-switch/archive/master.zip">3 (Stable)</a></li>
  40. <li><a href="https://github.com/nostalgiaz/bootstrap-switch/archive/v2.0.1.zip">2.0.1 (Legacy)</a></li>
  41. </ul>
  42. </li>
  43. <li><a href="index.html">Start</a></li>
  44. <li><a href="examples.html">Examples</a></li>
  45. <li class="dropdown"><a href="#" data-toggle="dropdown">Documentation<span class="caret"></span></a>
  46. <ul class="dropdown-menu">
  47. <li class="dropdown-header">Version 3 (Stable)</li>
  48. <li><a href="/options-3.html">Options</a></li>
  49. <li><a href="/methods-3.html">Methods</a></li>
  50. <li><a href="/events-3.html">Events</a></li>
  51. <li class="divider"></li>
  52. <li class="dropdown-header">Version 2.0.1 (Legacy)</li>
  53. <li><a href="/documentation-2.html">Documentation</a></li>
  54. </ul>
  55. </li>
  56. <li><a href="https://github.com/nostalgiaz/bootstrap-switch/issues">Bug reports</a></li>
  57. </ul>
  58. </nav>
  59. </div>
  60. </header>
  61. <div class="container content">
  62. <h1 class="page-header">Methods &nbsp;<small>Version 3 (Stable)</small></h1>
  63. <p>In Bootstrap Switch, every option is also a method.</p>
  64. <p>If the second parameter is omitted, the method return the current value.</p>
  65. <p>You can invoke methods as follows:</p>
  66. <pre><code>$('input[name="my-checkbox"]').bootstrapSwitch('state', true, true);</code></pre>
  67. <h2>Additional Methods</h2>
  68. <table class="table table-bordered table-striped table-responsive">
  69. <thead>
  70. <tr>
  71. <th>Name</th>
  72. <th>Description</th>
  73. </tr>
  74. </thead>
  75. <tbody>
  76. <tr>
  77. <td>toggleState</td>
  78. <td>Toggle the switch state</td>
  79. </tr>
  80. <tr>
  81. <td>toggleAnimate</td>
  82. <td>Toggle the animate option</td>
  83. </tr>
  84. <tr>
  85. <td>toggleDisabled</td>
  86. <td>Toggle the disabled state</td>
  87. </tr>
  88. <tr>
  89. <td>toggleReadonly</td>
  90. <td>Toggle the readonly state</td>
  91. </tr>
  92. <tr>
  93. <td>toggleIndeterminate</td>
  94. <td>Toggle the indeterminate state</td>
  95. </tr>
  96. <tr>
  97. <td>toggleInverse</td>
  98. <td>Toggle the inverse option</td>
  99. </tr>
  100. <tr>
  101. <td>destroy</td>
  102. <td>Destroy the instance of Bootstrap Switch</td>
  103. </tr>
  104. </tbody>
  105. </table>
  106. <h2>Special Behaviours</h2>
  107. <ul>
  108. <li>The method <code>state</code> can receive an optional third parameter <code>skip</code>. if true, <code>switchChange</code> event is not executed. The default is false.</li>
  109. <li>The method <code>toggleState</code> can receive an optional second parameter <code>skip</code>. if true, <code>switchChange</code> event is not executed. The default is false.</li>
  110. <li>The method <code>wrapperClass</code> can accepts a falsy value as second parameter. If so, it resets the class to its default.</li>
  111. </ul>
  112. </div>
  113. <div class="container bottom">
  114. <p>
  115. Licensed under the
  116. <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License, Version 2.0</a>
  117. · Created by
  118. <a href="https://github.com/nostalgiaz" target="_blank">Mattia Larentis</a>
  119. · Mantained by
  120. <a href="https://github.com/lostcrew" target="_blank">Emanuele Marchi</a>
  121. </p>
  122. </div>
  123. <script src="docs/js/jquery.min.js"></script>
  124. <script src="docs/js/bootstrap.min.js"></script>
  125. <script src="docs/js/highlight.js"></script>
  126. <script src="dist/js/bootstrap-switch.js"></script>
  127. <script src="docs/js/main.js"></script>
  128. </body>
  129. </html>