theironcook / Backbone.ModelBinder

Simple, flexible and powerful Model-View binding for Backbone.
1.42k stars 159 forks source link

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

Open technikhil314 opened 9 years ago

technikhil314 commented 9 years ago

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.

platinumazure commented 9 years ago

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 commented 9 years ago

Hi @platinumazure

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

amakhrov commented 9 years ago

this seems to have been fixed