Given the following form:
<form id="form" name="form">
<input name="name"/>
<input name="version"/>
<input name="template"/>
<textarea name="elements"></textarea>
<textarea name="features"></textarea>
<textarea name="layout"></textarea>
<input type="submit" value="Save"/>
</form>
and javascript (using jQuery 1.3.2):
$(function() {
$('#form').bind('submit',function() { alert($('#form').serialize()); return false; });
});
The output of submitting the above form from the above javascript alert is:
elements=...
Where ... is whatever is contained in the elements field.
I would expect that $('#form').serialize() to return a string something like:
name=&version=&template=&elements=&features=&layout=.
I do note that $('input,textarea').serialize() does perform the expected behaviour (i.e. return "name=&version=&template=&elements=asdafe&features=&layout="), however I'm curious as to why the $('#form') version only returns "elements=".
I've tried this on Safari 4 and Firefox 3.5, so I'm confident it's something I'm missing.
Thanks for reading.