[英]Ajax ActionLink OnSuccess call javascript function with parameters, Error: Object required
Using Ajax.ActionLink's OnSuccess-Event brings me some trouble. 使用Ajax.ActionLink的OnSuccess-Event给我带来了一些麻烦。
As asked here the function cannot be called directly. 如此处要求的那样,该函数不能直接调用。 I tried all the suggestions I found, I get a message "Object required".
我尝试了所有发现的建议,并收到消息“需要对象”。 The javascript-function expects an event, which is nothing/null when I pass it the correct way.
javascript函数需要一个事件,当我以正确的方式传递该事件时,该事件为空。
Before: 之前:
OnSuccess = "ListApi.ResetAddLink(window.event, '" + AdressListIndexName + "')",
After: 后:
OnSuccess = "function(){ListApi.ResetAddLink(window.event," + AdressListIndexName + ");}",
The Function ResetAddLink: 函数ResetAddLink:
ListApi.ResetAddLink = function(_evt, ListIndexName) {
evt = _evt || window.event;
var target = evt.target || evt.srcElement;
var Index = parseInt(document.getElementById(ListIndexName).value);
var Pre = target.href.substring(0, target.href.lastIndexOf("=") + 1);
Index = Index + 1;
document.getElementById(ListIndexName).value = Index;
target.href = Pre + Index;
}
I'm pretty new to Ajax and Javascript in general, maybe I miss just a little piece :( 总的来说,我对Ajax和Javascript还是很陌生,也许我只想念一小段:(
Thanks for any help 谢谢你的帮助
Regards 问候
PS: I know there are some troubles about adress and address, but I copy/pasted as it is for now. PS:我知道地址和地址有一些麻烦,但是我现在照原样复制/粘贴。 I also noticed that the error only occurs in internet explorer, firefox seems to get the event.
我还注意到,该错误仅发生在Internet Explorer中,Firefox似乎触发了该事件。
试图通过事件,但是没有用...所以我更改了参数,现在我从外部传递了事件所需的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.