jquery 手册
Ajax
属性(Attributes)
回调对象(Callbacks ..
核心(Core)
CSS
数据(Data)
延迟对象(Deferred o ..
尺寸(Dimensions)
效果(Effects)
事件(Events)
表单(Forms)
文档操作(Manipulati ..
杂项(Miscellaneou ..
位置(Offset)
插件编写(Plugin Aut ..
属性(Properties)
选择器(Selectors)
遍历(Traversing)
工具(Utilities)

Returns: undefinedundefined .callbacks.lock( )

Description: 将回调列表锁定在当前状态。
  • version added: 1.7
  • .callbacks.lock( )

Example

callbacks.lock() 锁定一个回调列表避免进一步改变列表状态:


<!DOCTYPE html>
<html>
<head>
  <script src="../jquery.min.js"></script>
  <body>
  <script>


// a sample logging function to be added to a callbacks list
var foo = function( value ){
    document.write( 'foo:' + value);
}

var callbacks = $.Callbacks();

// add the logging function to the callback list
callbacks.add( foo );

// fire the items on the list, passing an argument
callbacks.fire( 'hello' );
// outputs 'foo: hello'

// lock the callbacks list
callbacks.lock();

// try firing the items again
callbacks.fire( 'world' );

// as the list was locked, no items
// were called so 'world' isn't logged

</script>
</body>
</html>

Demo:

Examples: