Friday, October 31, 2008

[jQuery] Form plugin + Table Drag and Drop plugin

Hi, what I'm trying to do is when a user clicks on submit the form
sends all the form variables + the <tr> id's that tDnD generates
using
ajax.
Also when I tried to serialize the table outside the onDrop function
it generates an error.
I tried many ways to do it but without any success.
Ideas are:
************
1. serialize the table and serialize the form, then submit both
variables
2. concatenate both serialized variables and send it to the form
Question:
*************
1. I've tried to add parameters to formData variable, but I think
when
I call var queryString = $('#form1').formSerialize(); and then add
the
parameter, the validateForm sends only the form's variables, not the
added one.
My code:
*************
$(document).ready(function() {
// Initialise the table
$('#table1').tableDnD({
onDragStart: function(table, row) {$
("#submitBtn").removeAttr("disabled");},
onDrop: function(table, row) {//TODO: compare the last
state
with the new one}
});
$('#form1').submit(function() {
$(this).ajaxSubmit(options);
// !!! Important !!!
// always return false to prevent standard
browser submit and
page navigation
return false;
});
var options = {
target: '#resultDiv',
url: 'server.php',
beforeSubmit: validateForm,
resetForm: true,
success: function() {
}
}
function validateForm(formData, jqForm, options) {
jQuery.tableDnD.currentTable =
document.getElementById("#table1"); //Found in the plugin's page but
doesn't work
var length=
$.tableDnD.serialize('#table1'); //
Found in the plugin's page but doesn't work
var queryString = $('#form1').formSerialize();
queryString+=length;
alert(queryString);
return false;
}

Thanks to
**************
1. Everyone who wants to help
2. jQuery for making our life easier

No comments: