Module: BootstrapButtonHelper
- Extended by:
- ActiveSupport::Concern
- Includes:
- BootstrapHelper
- Defined in:
- app/helpers/bootstrap_button_helper.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ disabled: false, block: false, type: 'a', toggle: false }
- AVAI_SIZES =
['mini', 'small', 'large']
- AVAI_CLASSES =
['primary', 'secondary', 'info', 'success', 'warning', 'danger', 'inverse', 'link']
Instance Method Summary collapse
-
#bs_button(value = nil, options = {}, html_options = {}) ⇒ Object
(also: #btn)
Generate a bootstrap style button using a, button or submit.
Methods included from BootstrapHelper
#div, #javascript_include_tag_with_p, #merge_predef_class
Instance Method Details
#bs_button(value = nil, options = {}, html_options = {}) ⇒ Object Also known as: btn
Generate a bootstrap style button using a, button or submit
value: text of button options:
value: text of button if value is not passed
disabled: true, false. default: false
block: true, false. default: false
size: small, mini, large
class: primary, info, success, warning, danger, inverse, link
type: button, a, submit. default: button
toggle: true, false. default: false
icon: icon name, use glyph_icon
url: url will be directed while button is clicked
js: js will be executed while button is clicked
confirm: show confirmation text. only available with submit
disable_with: when clicked, this button will be disabled and text will be changed to. only available with submit
loading_text:
html_options:
any options that can be accpeted by a, button or submit.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/bootstrap_button_helper.rb', line 37 def (value=nil, ={}, ={}) , , value = , value, nil if value.is_a?(Hash) value = .delete(:value) if value.blank? .reverse_merge!(DEFAULT_OPTIONS) case .delete(:type) when 'button' render_btn(value, , ) when 'submit' render_submit(value, , ) when 'a' render_a(value, , ) else raise 'Error type of button, should be button or a' end end |