I'll post a working example below. Form submission and rendering any change are separated.
// use the jquery validate plugin to validate and submit
$( '#childForm' ).validate( {
// ignore: "",
rules: {
lastName: "required",
firstName: "required",
amountPerMonth: {
required: true,
number: true
},
startDateFamilyAssistanceDisplay: {
required: true,
dateEU: true
},
expirationDateFamilyAssistanceDisplay: {
required: false,
dateEU: true
}
},
messages: {
lastName: "",
firstName: "",
amountPerMonth: "",
startDateFamilyAssistanceDisplay: "",
expirationDateFamilyAssistanceDisplay: ""
},
submitHandler: function(form) {
// console.log('submitted ....');
var values = $('#childForm').serialize();
console.log(values);
// console.log(values);
$.post('index.cfm?p=emp.saveChild', values,
function(data,status) {
if(status == 'success'){
$("#children").trigger('refreshChildren');
$('#childDialog').dialog('close');
};
});
}
});
function renderChildren() {
var employeeId = $("#employeeIdMain").val();
$.post('index.cfm?p=emp.renderChildren',{employeeId:employeeId},
function(data,status) {
$("#children").html(data);
});
};
$("#children").bind('refreshChildren', renderChildren);
$("#children").trigger('refreshChildren');
Hope that might help you.