I have a page which dynamically brings in a form via ajax and displays it in a modal div (one that sits above an overlay div that covers the entire page). This is to let them save certain data before a window closes. Everything works great except one thing.
$('#save_close_form').find('*[name]').each(function(index, form_element) {
var cfe = (form_element.jquery == undefined ? $(form_element) : form_element);
console.log(cfe.attr('name') + " => " + cfe.attr('value'));
if (cfe.attr('name').match(/data\[/)) {
if (cfe.attr('type') == 'checkbox') {
if (cfe.attr('checked')) {
map[cfe.attr('name')] = 'on';
}
else {
map[cfe.attr('name')] = '';
}
}
else if (cfe.attr('type') == 'radio') {
// only get checked radio buttons
if (cfe.attr('checked')) {
map[cfe.attr('name')] = cfe.attr('value');
}
}
else {
map[cfe.attr('name')] = cfe.attr('value');
}
}
});
The part in the else {} clause at the end triggers for TextArea
and input type="text"
elements, but for some reason it always sees cfe.attr('value');
as undefined
for the TextArea
. I'm using FF6.0 with jQuery 1.6 for this.