Bootstrap-button-plugin
ブートストラップ-ボタンプラグイン
ボタンについては、リンク:/bootstrap/bootstrap_buttons [Bootstrap Buttons]で説明されています。 このプラグインを使用すると、コントロールボタンの状態などの相互作用を追加したり、ツールバーなどのコンポーネントのボタンのグループを作成したりできます。
'_このプラグイン機能を個別に含める場合は、 button.js が必要です。 または、リンク:/bootstrap/bootstrap_plugins_overview [Bootstrap Plugins Overview]で説明されているように、_bootstrap.js_または_bootstrap.min.js_を縮小したものを含めることができます。_
読み込み状態
ボタンに読み込み状態を追加するには、次の例に示すように、ボタン要素の属性として data-loading-text = "Loading …" を追加するだけです-
ボタンをクリックすると、出力は次の画像のようになります-
シングルトグル
トグルを有効にするには(つまり、 ボタンの通常の状態をプッシュ状態に、またはその逆に変更します)、単一のボタンで、次の例に示すように、ボタン要素に属性として data-toggle = "button" を追加します-
チェックボックス
データ属性 data-toggle = "buttons" を* btn-group。*に追加するだけで、チェックボックスのグループを作成し、トグルを追加できます。
無線
同様に、ラジオ属性のグループを作成し、データ属性 data-toggle = "buttons" を btn-group に追加するだけで、切り替えを追加できます。
使用法
以下に示すように、JavaScript経由でボタンプラグインを有効にできます-
オプション
オプションはありません。
方法
以下にボタンプラグインの便利なメソッドの一部を示します-
Method | Description | Example |
---|---|---|
button('toggle') | Toggles push state. Gives the button the appearance that it has been activated. You can also enable auto toggling of a button by using the *data-toggle *attribute. | |
.button('loading') | When loading, the button is disabled and the text is changed to the option from the* data-loading-text* attribute of button element | |
.button('reset') | Resets button state, bringing the original content back to the text. This method is useful when you need to return the button back to the primary state | |
.button(string) | String in this method is referring to any string declared by the user. To reset the button state and bring in new content use this method. |
例
次の例は、上記の方法の使用を示しています-