开发者

MVC3 Ajax UpdateTargetId bypassed

开发者 https://www.devze.com 2023-03-14 05:04 出处:网络
I have a MVC View that generates multiple Ajax.BeginForm, with a button in them that calls a function in the Controller that returns a Partial View. The UpdateTarget开发者_如何学GoId is set to the ID

I have a MVC View that generates multiple Ajax.BeginForm, with a button in them that calls a function in the Controller that returns a Partial View. The UpdateTarget开发者_如何学GoId is set to the ID of a Div. It works fine if I manually click the button, but if I use this code...

<script type="text/javascript">
    $(document).ready(function () {
        $(".submitButton").click();
    });
</script>

Then it clicks the button alright, but it opens the Partial View in a new page... Why does this happen, and how can I fix this?


You probably want to submit the form directly, instead of clicking the submit button. perhaps

$('#formID').submit();

Will help with what you're after.

0

精彩评论

暂无评论...
验证码 换一张
取 消