$("table.dynatable button.add").click(function() {
var form = this.form;
id++;
// Get a new row based on the prototype row
//var prot = master.find(".prototype").clone();
var prot = $(form).data('prototype').clone();
prot.find('[name^="id"]').attr("value", id);
prot.find('[name^="locationFrom"]').attr('name', 'locationFrom[' + id + ']');
prot.find('[name^="locationFrom"]').attr('id', 'locationFrom[' + id + ']');
prot.find('[name^="locationFrom"]').attr('value', '');
prot.find('[name^="eventFrom"]').attr('name', 'eventFrom[' + id + ']');
prot.find('[name^="eventFrom"]').attr('value', '');
prot.find('[name^="locationTo"]').attr('name', 'locationTo[' + id + ']');
prot.find('[name^="locationTo"]').attr('value', '');
prot.find('[name^="eventTo"]').attr('name', 'eventTo[' + id + ']');
prot.find('[name^="eventTo"]').attr('value', '');
//var dropLocationFromName = 'locationFrom[' + id + ']';
//alert("dropLocationFromName : "+dropLocationFromName);
//$(form).find("dynamicRow").append(prot);
$("#dynamicRow").find('tbody').append(prot);
//$("#form1").validate();
//$('#' + dropLocationFromName).rules('add', {required: true});
assignRules(form);
return false;
});
function assignRules(form)
{
$('td:nth-child(2) select',form).each(function ()
{
$(this).rules('add', {required:
function(element) {
return $(element).val()!=$("#locationTo").val();
);
}
}
Bookmarks