Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If called copyViewValuesToModel the radio button with checked attribute in html gets checked and model gets the value. #199

Open
technikhil314 opened this issue Jan 24, 2015 · 3 comments

Comments

@technikhil314
Copy link
Contributor

I had written html with a group of radio buttons, in which I had added checked attribute to first radio button to make it checked by default when view is rendered. On the same form on change event of another element I had called copyViewValuesToModel function.After adding the call I find that the radio which had checked attribute gets checked though if I had changed the selection in radio button group.On debugging I found on line 303 of backbone.modelbinder.js the code is
if(el.attr('type') === 'radio' && el.attr('checked')) which should be
if(el.attr('type') === 'radio' && el.is(':checked')). Correct me if I am wrong.

@technikhil314 technikhil314 changed the title if called copyViewValuesToModel the radio which is default checked in html gets checked and model gets the value. If called copyViewValuesToModel the radio button with checked attribute in html gets checked and model gets the value. Jan 24, 2015
@platinumazure
Copy link
Contributor

Hi @nikhil-001mehta,

I would favor el.prop('checked') myself, but I agree that el.attr('checked') seems fishy/off there. If you get a chance, would you mind seeing if using prop will work too?

Did you want to open a pull request to fix this, or would you like me or someone else to do so?

@technikhil314
Copy link
Contributor Author

Hi @platinumazure

I yes the prop is working.so I will open a pull request soon.

@amakhrov
Copy link
Contributor

amakhrov commented Aug 8, 2015

this seems to have been fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants