DOJO-API中文参考手册附加注解实例(5)

2019-03-03 21:34

dojo.event.connect(scope1, \dojo.event.connect(\//

\

dojo.event.connect(scope1, \scope2, //

\//

\// // // // // //

dojo.event.connect(\scope1, \scope2, dojo.event.connect(\scope1, \scope2, dojo.event.connect(\scope1, \scope2, \aroundFunctionReference); dojo.event.connect(\scope1, \scope2, \scope3,

\// //

\//

dojo.event.connect(\‐around\scope1, \scope2,

aroundFunctionReference); // dojo.event.connect(\‐around\//

\

scope1, \scope2, //

aroundFunctionReference); // dojo.event.connect(\‐around\//

\//

\scope1, \scope2, scope3, true, 30); // // // // // //

dojo.event.connect(\scope1, \scope2, \

scope3, \dojo.event.connect(\scope1, \

scope2, \

scope3, \null, null, 10); // adviceType: // //

// srcObj: // // // // //

Optional. String. One of \\‐around\‐around\

the scope in which to locate/execute the named srcFunc. Along with srcFunc, this creates a way to dereference the function to call. So if the function in question is \

srcObj/srcFunc pair would be foo and \string and foo is an object reference. // srcFunc: // // // //

the name of the function to connect to. When it is executed, the listener being registered with this call will be called. The adviceType defines the call order between the source and the target functions. // adviceObj: //

the scope in which to locate/execute the named adviceFunc. // adviceFunc: //

the name of the function being conected to srcObj.srcFunc // aroundObj: //

the scope in which to locate/execute the named aroundFunc. // aroundFunc: // // // // // // // //

the name of, or a reference to, the function that will be used to mediate the advice call. Around advice requires a special unary function that will be passed a \These objects have several important properties, namely: ‐ args

a mutable array of arguments to be passed into the wrapped function ‐ proceed // // // //

// once:

// // //

// delay: // //

// rate: // // //

a function that \of this function is the return of the wrapped function. You can then manipulate this return before passing it back out (or take further action based on it).

boolean that determines whether or not this connect() will create a new connection if an identical connect() has already been made. Defaults to \

an optional delay (in ms), as an integer, for dispatch of a listener after the source has been fired.

an optional rate throttling parameter (integer, in ms). When specified, this particular connection will not fire more than once in the interval specified by the rate // adviceMsg: // // /* */

Usage Example: 简单绑定 1

function doOnClick1() {

alert( \}

boolean. Should the listener have all the parameters passed in as a single argument? ao.adviceType = args[0]; ao.srcObj = args[1]; ao.srcFunc = args[2]; ao.adviceObj = args[3] ao.adviceFunc = args[4]; ao.aroundObj = args[5]; ao.aroundFunc = args[6]; ao.once = args[7]; ao.delay = args[8]; ao.rate = args[9];

ao.adviceMsg = args[10]; ao.maxCalls = args[11];

dojo.event.connect(dojo.byId(\简单绑定 2

obj = { doOnClick2: function(){ alert(\

dojo.event.connect(dojo.byId(\如果存在需要进行多个事件的绑定的时候,你就会看到 dojo 的方便之处了 obj2 = { doOnClick2: function(){alert(\

dojo.event.connect(dojo.byId(\dojo.event.connect(dojo.byId(\connect 可以对任何对象的方法进行绑定,而不是只能针对 DOM 对象

dojo.event.connect(obj,\在调用 obj.doOnclick2()后调用 doOnClick1() dojo.event.log

function(/*object or funcName*/ a1, /*funcName*/ a2)

// summary: // // // //

// a1: // //

// a2: //

a function that will wrap and log all calls to the specified a1.a2() function. If only a1 is passed, it'll be used as a function or function name on the global context. Logging will be sent to dojo.debug

if a2 is passed, this should be an object. If not, it can be a function or function name. a function name

dojo.event.connectBefore function()summary: // //

takes the same parameters as dojo.event.connect(), except that the advice type will always be \

dojo.event.connect 默认是后绑定,connectBefore 则是早绑定,绑定的方法将在指定方法前执行,用法与 connect 一致 dojo.event.connectAround summary: // //

takes the same parameters as dojo.event.connect(), except that the advice type will always be \Usage Example:

function aroundTest(invocation){

//此处可以增加代码,比如检查参数(invocation.args) var result = invocation.proceed();

//此处可以增加代码,比如修改结果(result) return result; }

dojo.event.connectAround(dojo.byId(\dojo.event.connectOnce function() summary: // //

takes the same parameters as dojo.event.connect(), except that the \

说起这个函数,还真的是让我想了半天,直觉上我就把它想象成 executeOnce,结果测试的结 果让我差点想不通

connectOnce 就是指保证只绑定一次,来避免重复绑定会导致的重复执行的问题 dojo.event.connectRunOnce summary: // //

takes the same parameters as dojo.event.connect(), except that the \dojo.event.kwConnect

kwConnect 可以做到更加灵活的绑定,比如可以设置延迟执行绑定 function(/*Object*/ kwArgs) summary: //

A version of dojo.event.connect() that takes a map of named // // // //

parameters instead of the positional parameters that

dojo.event.connect() uses. For many advanced connection types, this can be a much more readable (and potentially faster) alternative. // kwArgs: // // // // // // // // // // // // // //

An object that can have the following properties: ‐ adviceType ‐ srcObj ‐ srcFunc ‐ adviceObj ‐ adviceFunc ‐ aroundObj ‐ aroundFunc ‐ once ‐ delay ‐ rate

‐ adviceMsg

As with connect, only srcFunc and adviceFunc are generally required

Usage Example:

dojo.event.kwConnect({

srcObj: dojo.byId(\ srcFunc: \ adviceObj: obj,

adviceFunc: \

type: \默认为\,可选: \,注意:type 是用来决定 adviceFunc 的行为的,如果为\

ound\,则 aroundFunc 将失效 aroundObj: null,

aroundFunc: null, //如果指定了 aroundFunc,则其将对 adviceFunc 进行拦截,但是当 type 为 \时,则 aroun dFunc 将不会执行

once: false, //默认为 false,允许重复绑定 delay: 3000, //延时 3 秒后执行 adviceFunc rate: 0, //这个从源代码没有看懂起什么作用

adviceMsg: false //这个从源代码没有看懂起什么作用 });

dojo.event.kwDisconnect

用来解除使用 kwConnect 指定的绑定 模块:dojo.event.topic

Topic 机制与 Advice 机制都能够实现事件的绑定,但是显然,Topic 更适合处理多重绑定。


DOJO-API中文参考手册附加注解实例(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:国际物流历年试题

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: