zoukankan      html  css  js  c++  java
  • jQuery慢慢啃之回调(十三)

    1.callbacks.add(callbacks)//回调列表中添加一个回调或回调的集合

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( 'foo:' + value );
    }
    
    // another function to also be added to the list
    var bar = function( value ){
        console.log( 'bar:' + value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the function 'foo' to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'hello' );  
    // outputs: 'foo: hello'
    
    // add the function 'bar' to the list
    callbacks.add( bar );
    
    // fire the items on the list again
    callbacks.fire( 'world' );  
    
    // outputs:
    // 'foo: world'
    // 'bar: world'

    2.callbacks.disable()//禁用回调列表中的回调 

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the above function to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'foo' ); // outputs: foo
    
    // disable further calls being possible
    callbacks.disable();
    
    // attempt to fire with 'foobar' as an argument
    callbacks.fire( 'foobar' ); // foobar isn't output

    3.callbacks.empty()//从列表中删除所有的回调.

    // a sample logging function to be added to a callbacks list
    var foo = function( value1, value2 ){
        console.log( 'foo:' + value1 + ',' + value2 );
    }
    
    // another function to also be added to the list
    var bar = function( value1, value2 ){
        console.log( 'bar:' + value1 + ',' + value2 );
    }
    
    var callbacks = $.Callbacks();
    
    // add the two functions
    callbacks.add( foo );
    callbacks.add( bar );
    
    // empty the callbacks list
    callbacks.empty();
    
    // check to ensure all callbacks have been removed
    console.log( callbacks.has( foo ) ); // false
    console.log( callbacks.has( bar ) ); // false

    4.callbacks.fire(arguments)//禁用回调列表中的回调 

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( 'foo:' + value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the function 'foo' to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'hello' ); // outputs: 'foo: hello'
    callbacks.fire( 'world '); // outputs: 'foo: world'
    
    // add another function to the list
    var bar = function( value ){
        console.log( 'bar:' + value );
    } 
    
    // add this function to the list
    callbacks.add( bar );
    
    // fire the items on the list again
    callbacks.fire( 'hello again' );
    // outputs:
    // 'foo: hello again'
    // 'bar: hello again'

    5.callbacks.fired()//用给定的参数调用所有的回调。

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( 'foo:' + value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the function 'foo' to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'hello' ); // outputs: 'foo: hello'
    callbacks.fire( 'world '); // outputs: 'foo: world'
    
    // test to establish if the callbacks have been called
    console.log( callbacks.fired() );

    6.callbacks.fireWith([context][,args])//访问给定的上下文和参数列表中的所有回调

    7.callbacks.has(callback)//确定是否提供的回调列表 

    8.callbacks.lock()//锁定在其当前状态的回调列表。 

    9.callbacks.locked()//确定是否已被锁定的回调列表

    10.callbacks.remove(callbacks)//删除回调或回调回调列表的集合。 

    11.jQuery.callbacks(flags)//一个多用途的回调列表对象,提供了强大的的方式来管理回调函数列表。

  • 相关阅读:
    Microsoft Security Essentials
    android studio 引用远程仓库下载慢(JCenter下载慢)的办法
    Android studio Unable to start the daemon process
    Android studio 怎么使用已经下载好的Android SDK ?
    解决Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!
    U3d中实现A*寻路,附源文件
    [运维-服务器 – 1A] – nginx.conf(转)
    unity客户端与c++服务器之间的简单通讯_1
    [Java Web – Maven – 1A]maven 3.3.3 for windows 配置(转)
    [Android-2A] -仿IOS微信滑动删除_SwipeListview左滑删除例子
  • 原文地址:https://www.cnblogs.com/yuliantao/p/4277240.html
Copyright © 2011-2022 走看看