serializeArray 's problem
erstens opened this issue · 1 comments
erstens commented
<form id="f1">
<input name='status' type='radio' value='0' checked/><!-- check this -->
<input name='status' type='radio' value='-1'/>
</form>
<form id="f2">
<input name='status' type='radio' value='1' checked/>
<input name='status' type='radio' value='2'/><!-- after check this -->
</form>
//use
var form = $('#f2').serializeObject() ;
alert(form.status) ; //print '0'
//why ???
//use serializeArray() ,'form.status' ,print 0
I need your help .
macek commented
Unless I'm overlooking something, this issue appears to be invalid. I added a test to assert that your forms are encoding correctly. Both assertions passed without having to change any code
it("should pass issue #107", function() {
var $form1 = $('<form id="f1"><input name="a" type="radio" value="0" checked/><input name="a" type="radio" value="-1"/></form>');
var $form2 = $('<form id="f2"><input name="a" type="radio" value="1" checked/><input name="a" type="radio" value="2"/></form>');
assert.deepEqual($form1.serializeObject(), {a: "0"});
assert.deepEqual($form2.serializeObject(), {a: "1"});
});
If you're still having trouble, can you provide more info?