I am attempting to submit a form contained in a parent window from a child iframe using jQuery without much luck.
In the child window I have the following validation function:
<script type="text/javascript" src="templates/js/jquery.js"></script>
<script type="text/javascript" src="templates/js/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$("#form_invoice_item").validate({
submitHandler: function (form) {
// Check if main invoice already saved
if ($('#invoice_id').val() == "") {
// Change target to processing iframe
try {
parent.$('#invoice_form').ajaxSubmit();
} catch(e) { //debug
alert ("Error:" + e);
}
} else {
alert ("Saving invoice " + $('#invoice_id').val() + ' items'); }
//form.submit(); //debug
}
});
});
</script>
<form method="post" id="form_invoice_item" name="form_invoice_item" action="index.php" target="invoice_items">
The error that occurs at parent.$('#invoice_form').ajaxSubmit();
is
Error:TypeError: Object [object Object] has no method 'ajaxSubmit'
If I use the following snippet which is just in plain Javascript, there is no problem(Obviously this isn't jQuery but it gets the job done). How do i do this in jQuery:
parent.document.getElementById('invoice_form').target='process';
parent.document.getElementById('invoice_form').submit();
parent.document.getElementById('invoice_form').target='';
I have a hidden iframe called process which has its display property set to hidden.