Skip to content

Bootstrap Switch Checkbox

Stella Rouzi edited this page Mar 2, 2015 · 7 revisions

Bootstrap Switch Checkbox

http://www.bootstrap-switch.org/

Usage:

With a = check_box_tag

  • you must add the class switch_checkbox and
  • set as model variable the name of the model (as it will be used in the link, eg. events)
  • set as attribute variable the name of the attribute you want to change (eg. is_highlight)

Eg. the following code produces a switch checkbox for event model and changes the attribute require_registration

= check_box_tag @conference.short_title, event.id, event.require_registration, model: 'events', attribute: 'require_registration', class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', off_text: 'No' }

Which will look like this, when require_registration is true:

switch-checkbox-on

And like this when require_registration is false:

switch-checkbox-off

Clone this wiki locally