Using bootstrap-switch with Rails' check_box -


i need display checkbox user's field. using:

<%= f.label :is_name_public, "public name" %> <%= f.check_box :is_name_public %> 

now want use bootstrap-switch rails' chech_box. in order use switch button, checkbox needs like:

<input id="user_is_name_public" name="user[is_name_public]" type="checkbox" value="1" data-size="small" data-on-color="success" data-on-text="yes" data-off-text="no">

instead of rails' default:

<input id="user_is_name_public" name="user[is_name_public]" type="checkbox" value="1">

the question is, how tell rails add custom properties data-size="small" or data-on-color="success" checkbox? or how associate custom html checkbox entity being edited form?

you can add more attributes default ones:

<%= f.check_box :is_name_public, :class => 'someclass' %> 

the same true data attribute:

<%= f.check_box :is_name_public, :data => { :size => 'small', 'on-color'=>'success'} %> 

notice how :data => { :size => 'small' … bit transformed data-size="small" in resulting html.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -