The forthcoming jQuery release, version 1.4.3, should include form data linking. Currently these features can be tested via a fork of jQuery and a plugin, both available in Github.
// Data which is linked to the form
var linked = {};
// Once DOM is completely downloaded, thus ready, this is triggered
$(document).ready(function() {
$('#profile_form').link(linked);
$('input, select').change(function() {
printInfo();
});
$('input[name=send]:button').click(function() {
printInfo();
});
$(linked).data('username', 'Tonttu');
$('input[name=password]').val('joulupukki');
printInfo();
});
// Print visual feedback of the current values
function printInfo() {
var str = '';
for (var i in linked) {
if (linked.hasOwnProperty(i)) {
str += '<' + 'p>linked.' + i + ': ' + linked[i] + '<' + '/p>';
}
}
$('#info').html(str);
}The above example is available with the rest of the DOM elements in the html file attached.






















