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)//一个多用途的回调列表对象,提供了强大的的方式来管理回调函数列表。

  • 相关阅读:
    并查集
    树状数组及二维树状数组
    maven工程编译成jar包
    The Salt Master has rejected this minion's public key!
    salt-minion dead but pid file exists 正确解决方法
    mysql 查找表的auto_increment和修改
    fastjson --JSONObject 和JSONArray 转换
    git 获取当前版本的commitid
    fastjson 使用笔记
    spring IOC 注解@Resource
  • 原文地址:https://www.cnblogs.com/yuliantao/p/4277240.html
Copyright © 2011-2022 走看看