JQuery validation not running when submitted by a button from outside of IFrame
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 开发者_StackOverflow社区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?
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>
精彩评论