附加jQuery的事件提交我的Ajax.BeginForm [英] Additional jQuery events submitting my Ajax.BeginForm

查看:429
本文介绍了附加jQuery的事件提交我的Ajax.BeginForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.Net MVC Ajax.BeginForm的提交并妥善地更新我的页面,当我点击提交按钮。

I have an ASP.Net MVC Ajax.BeginForm that submits and updates my page properly when I click the submit button.

问题是,我需要更多的事件做同样的事情,当他们更改输入文本等。该事件产生额外做正确提交表单,但他们绕过由Ajax.BeginForm表单标签生成的onsubmit的javascript。

The problem is I need additional events to do the same thing, like when they change the text of an input. The additonal events do properly submit the form but they circumvent the onsubmit javascript generated on the form tag by the Ajax.BeginForm.

下面是Ajax.BeingForm生成的表单标签:

Here is the form tag generated by Ajax.BeingForm:

<form action="/Store/UpdateCart" method="post" onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'updatedContent' });">

这是绑定我需要通过Ajax提交表单其他事件jQuery的:

And here is the jQuery to bind my other events that need to submit the form via Ajax:

 $("#ShippingType, #ViewCart .ddl").bind("change", function() { $("#ViewCartPage form").submit() });

这是如何获得这些额外的事件触发的onsubmit像我需要它太任何想法?

Any ideas on how to get these additional events to trigger onsubmit like I need it too?

推荐答案

决定只使用常规的表单,然后将jQuery.Form插件,这个工作在2秒内!希望我刚才去这条路线orginally。

Decided to just use a regular form and then the jQuery.Form plugin and this worked in 2 seconds! Wish i would have just went this route orginally.

var options = {
   target: '#updatedContent',   // target element(s) to be updated with server response 
   beforeSubmit: showRequest,  // pre-submit callback 
   success: showResponse  // post-submit callback 
        };

$('#ViewCartPage form').ajaxForm(options);

我爱的男人的jQuery

Man I love jQuery

这篇关于附加jQuery的事件提交我的Ajax.BeginForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆