jQuery中的Ajax ASP.Net的Function.createDelegate等效 [英] Equivalent of ASP.Net Ajax Function.createDelegate in jQuery

查看:116
本文介绍了jQuery中的Ajax ASP.Net的Function.createDelegate等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图端口通过ASP.Net AJAX的行为变成一个jQuery插件。一块拼图剩下的解决是找到了jQuery的一个Function.createDelegate代替。

I was trying to port over a ASP.Net ajax behavior into a jQuery plugin. A piece of puzzle that remains solving is to find a substitute for Function.createDelegate in jQuery.

我需要在jQuery的是这样的:

I need something like this in jQuery:

this.$delegateOnClick = Function.createDelegate(this, this.fireOnClick);

时的jQuery .delegate方法要走的路?

Is jQuery .delegate method the way to go?

或者是这个职位:<一href=\"http://stackoverflow.com/questions/520019/controlling-the-value-of-this-in-a-jquery-event/520417#520417\">Controlling的这个'在一个jQuery事件中的价值

推荐答案

我想你想jQuery的 $。代理()功能。有两种形式:

I think you want the jQuery $.proxy() function. There are two forms:

var proxy = $.proxy(someFunction, someObject); // A
var proxy2 = $.proxy(someObject, someString); // B

在A调用返回的函数,这样当它被称为,功能someFunction将与任何参数调用你传递的代理并以这个绑定到someObject。在B版本相似,但不是你,你在指一些功能的名称的关于someObject的属性传递一个函数传递。因此,如果你有一个对象小工具有一个叫功能闪烁,然后

The "A" invocation returns a function such that when it's called, the function "someFunction" will be called with whatever arguments you passed the proxy and with "this" bound to "someObject". The "B" version is similar, but instead of you passing in a function you pass in the name of a property on "someObject" that refers to some function. Thus, if you have an object "widget" with a function called "blink", then

var blinker = $.proxy(widget, "blink");

为您提供了将调用的小部件(即用这个必然小部件)中的闪烁功能的功能。

gives you a function that will invoke the "blink" function on "widget" (that is, with "this" bound to "widget").

这篇关于jQuery中的Ajax ASP.Net的Function.createDelegate等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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