加载中...

callbacks.fireWith()1.7+


概述    callbacks.fireWith( [context ] [, args ] )

返回值:Callbacks

描述:访问给定的上下文和参数列表中的所有回调。

  • V : 1.7callbacks.fireWith( [context ] [, args ] )

    • context
      Type:
      该列表中的回调被触发的上下文引用
    • args
      Type:
      一个参数或参数列表传回给回调列表。

此方法返回绑定它的那个回调对象(this).

示例

实例

使用 callbacks.fireWith() 访问给定的上下文和参数列表中的所有回调。

jQuery 代码:
  1. // a sample logging function to be added to a callbacks list
  2. var log = function( value1, value2 ){
  3. console.log( 'Received:' + value1 + ',' + value2 );
  4. }
  5. var callbacks = $.Callbacks();
  6. // add the log method to the callbacks list
  7. callbacks.add( log );
  8. // fire the callbacks on the list using the context 'window'
  9. // and an arguments array
  10. callbacks.fireWith( window, ['foo','bar']);
  11. // outputs: Received: foo, bar

还没有评论.