如何通过调用AJAX.BeginForm的成功名称来获取表单或div [英] How to get the form or div by name which the AJAX.BeginForm' onsuccess is called

查看:126
本文介绍了如何通过调用AJAX.BeginForm的成功名称来获取表单或div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在div元素内调用了Ajax.BeginForm,所以我想获取表单所在的div元素。即,我想要一个等价的

I have called Ajax.BeginForm inside a div element, so I want to get the div element which the form is in. i.e. I want an equivalent of

function function1(event){
var table = $(event.target).parents("table");
}

可以在Ajax.beginform的onsuccess函数中使用。有人可以在这里提供帮助吗?

which can be used from the Ajax.beginform's onsuccess function. Can anyone help here?

推荐答案

事实证明,在onsuccess函数中, this是指form元素。这样我就可以轻松使用

It turned out that, within the onsuccess function, "this" refers to the form element. So I could easily use,

$(this).find("mydiv");

$(this).parent("table").find("mydiv");

这篇关于如何通过调用AJAX.BeginForm的成功名称来获取表单或div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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