Hey,
I was using your jQuery plugin and have encountered this weird behaviour.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.serialize-object.js"></script>
</head>
<body>
<form id="new_form">
User Name:
<input type="text" name="agent_signup[user_name]">
<br>
User Email:
<input type="text" name="agent_signup[user_user_emails_attributes[0][email]]">
<br>
Agent Role
<input type="checkbox" name="agent_signup[role_ids][]" value="1">Account Administrator
<input type="checkbox" name="agent_signup[role_ids][]" value="2">Administrator
<input type="checkbox" name="agent_signup[role_ids][]" value="4">Agent
<input type="checkbox" name="agent_signup[role_ids][]" value="3">Supervisor
<button>Submit</button>
</form>
</body>
</html>
To serialize the form, I ran
$("#new_form").serializeObject()
The returned object was
"{"agent_signup":{"user_name":"tushar","user_user_emails_attributes[0":{"email]":"[email protected]"},"role_ids":["1","4"]}}"
whereas the expected object is
"{"agent_signup":{"user_name":"tushar","user_user_emails_attributes":{"0":{"email":"[email protected]"}},"role_ids":["1","4"]}}"
Hey,
I was using your jQuery plugin and have encountered this weird behaviour.
To serialize the form, I ran
The returned object was
whereas the expected object is