我可以传递参数,在一个Ajax.ActionLink中的onSuccess事件 [英] Can I pass a parameter with the OnSuccess event in a Ajax.ActionLink

查看:741
本文介绍了我可以传递参数,在一个Ajax.ActionLink中的onSuccess事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用:

new AjaxOptions
{
  UpdateTargetId = "VoteCount" + indx,
  OnSuccess = "AnimateVoteMessage"
}

一切工作正常...但我想在列表中的项目动画与自动分配的ID。因为我希望每个这些是从我的JavaScript寻址的,我相信我需要一个参数传递给我的javascript。但是当我使用:

everything works fine...but I am trying to animate items in a list, with automatically assigned ID's. Since I want each of these to be addressable from my javascript, I believe I need to pass a parameter to my javascript. But when I use:

new AjaxOptions
{ 
  UpdateTargetId = "VoteCount" + indx,
  OnSuccess = "AnimateVoteMessage(2)"
}

我得到一个Sys.ArgumentUndefinedException:值不能为未定义。例外。好吧,我得到使用MicrosoftMvcAjax.js的调试版本时。当使用COM pressed版本,我得到一个Microsoft JScript运行时错误:'B'为空或不是对象

I get an " Sys.ArgumentUndefinedException: Value cannot be undefined." exception. Well I get that when using the debug versions of MicrosoftMvcAjax.js. When using the compressed version I get a "Microsoft JScript runtime error: 'b' is null or not an object"

所以我的问题是,使用了的onSuccess 事件中,我可以将参数传递给我的javascript函数 ActionLink的

So my question is, can I pass a parameter to my javascript function using the OnSuccess event for a ActionLink?

这是正确的做法?怎么回事我要去有一个JavaScript函数有能力要在10个项目我的网页上运行(在我的情况下,多个div的ID)?

Is this the right approach? How else am I going to have one javascript function have the ability to be run on 10 items (in my case the IDs of multiple DIVs) on my page?

推荐答案

或...有点不同的语法为我工作:

or...a bit different syntax that worked for me:

OnSuccess = "( function() { MyFunction(arg1,arg2); } )"

这篇关于我可以传递参数,在一个Ajax.ActionLink中的onSuccess事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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