Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Simple_form checkbox returns both '1' for either checked or unchecked #6860

Closed
emclab opened this Issue · 4 comments

4 participants

@emclab

Here is checkbox we used in simple_form with bootstrap:

<%= f.input :user_for_customer, :as => :boolean %>

It shows a checkbox on the page. However the js var rpt below always returns '1' for the checkbox either checked or unchecked:

//show customer_id if user_for_customer checked
$(function(){
$('#user_user_for_customer').change(function(){
var rpt = $('#user_user_for_customer').val();
alert(rpt);
if (rpt == '1'){
$('#user_customer').show();
} else {
$('#user_customer').hide();
}

});

});

Is it a bug in bootstrap? The code is running on win8 & rails 3.2.11, ruby 1.9.3

@cvrebert
Owner

No, it doesn't modify stuff drastically enough to break such basic behavior. Debug your JS/markup.

@blakeembrey

@emclab Your doing it wrong. If you want to find out if something is checked, use .prop('checked') - value will always return 1 since that is the checkbox value.

@mdo
Owner
mdo commented

Not a Bootstrap issue.

@mdo mdo closed this
@emclab

thanks anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.