开发者

MVC3 Ajax UpdateTargetId bypassed

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜