Reputation: 38035
I am using JQuery UI dialog to host a form that is inside of an IFrame. I am saving the form by calling...
$(myIframe).contents().find('form').submit()
...from the dialogs save button.
This will submit the form, but it doesn't seem to call the validation (I'm using JQuery unobtrusive validation). If I place a submit button inside the IFrame it works just fine, so I know the validation logic is correct.
How do I get the validation to run properly?
Upvotes: 1
Views: 926
Reputation: 38035
Instead of calling the jquery submit function directly from the parent window, call a method inside of the IFrame that calls the submit method.
Parent window...
<script type="text/javascript">
$(function () {
$('#btnSubmit').click(function () {
myFrame.submitForm();
});
});
</script>
Child window...
<script type="text/javascript">
function submitForm() {
$('form').submit();
}
</script>
Upvotes: 1