jQuery.Callbacks()
jQuery.Callbacks( flags )
:
: 1.7jQuery.Callbacks( flags )
flags
: String
,
$.Callbacks()jQuery$.ajax() $.Deferred()
$.Callbacks() callbacks.add(),callbacks.remove(), callbacks.fire() and callbacks.disable().
Getting started()
fn1 fn2:
function fn1( value ) {
console.log( value );
}
function fn2( value ) {
fn1(“fn2 says: ” + value);
return false;
}
$.Callbacks:
var callbacks = $.Callbacks();
callbacks.add( fn1 );
// outputs: foo!
callbacks.fire( “foo!” );
callbacks.add( fn2 );
// outputs: bar!, fn2 says: bar!
callbacks.fire( “bar!” );
.add() .fire() .add() , .fire() .
$.Callbacks .remove免费云主机、域名().remove() :
var callbacks = $.Callbacks();
callbacks.add( fn1 );
// outputs: foo!
callbacks.fire( “foo!” );
callbacks.add( fn2 );
// outputs: bar!, fn2 says: bar!
callbacks.fire( “bar!” );
callbacks.remove( fn2 );
// only outputs foobar, as fn2 has been removed.
callbacks.fire( “foobar” );
Supported Flags Flags
flags $.Callbacks(), , (. $.Callbacks( ‘unique stopOnFalse’ )).jQuery.Callbacks()!
本篇内容介绍了“怎么写出干净的JS代码”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!我们常常会用到数字,比如以下代码:谁知道这个 100 具体指的是什么?我们通…