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)//一个多用途的回调列表对象,提供了强大的的方式来管理回调函数列表。
jQuery慢慢啃之回调(十三)的更多相关文章
- jQuery慢慢啃之工具(十)
1.jQuery.support//一组用于展示不同浏览器各自特性和bug的属性集合 2.jQuery.browser//浏览器内核标识.依据 navigator.userAgent 判断. 可用值: ...
- jQuery慢慢啃之ajax(九)
1.jQuery.ajax(url,[settings])//通过 HTTP 请求加载远程数据 如果要处理$.ajax()得到的数据,则需要使用回调函数.beforeSend.error.dataFi ...
- jQuery慢慢啃之特效(八)
1.show([speed,[easing],[fn]])\\显示隐藏的匹配元素 //speed:三种预定速度之一的字符串("slow","normal", o ...
- jQuery慢慢啃之事件对象(十一)
1.event.currentTarget//在事件冒泡阶段中的当前DOM元素 $("p").click(function(event) { alert( event.curren ...
- jQuery慢慢啃之事件(七)
1.ready(fn)//当DOM载入就绪可以查询及操纵时绑定一个要执行的函数. $(document).ready(function(){ // 在这里写你的代码...}); 使用 $(docume ...
- jQuery慢慢啃之CSS(六)
1.css(name|pro|[,val|fn])//访问匹配元素的样式属性 $("p").css("color");//获取 $("p") ...
- jQuery慢慢啃之文档处理(五)
1.append(content|fn)//向每个匹配的元素内部追加内容. $("p").append("<b>Hello</b>"); ...
- jQuery慢慢啃筛选(四)
1.eq(index|-index) 获取第N个元素 其中负数:一个整数,指示元素的位置,从集合中的最后一个元素开始倒数.(1算起) $("p").eq(1)//获取匹配的第二个元 ...
- jQuery慢慢啃之核心(一)
1. $("div > p"); div 元素的所有p子元素. $(document.body).css( "background", "bla ...
随机推荐
- Django中的ORM进阶操作
Django中的ORM进阶操作 Django中是通过ORM来操作数据库的,通过ORM可以很easy的实现与数据库的交互.但是仍然有几种操作是非常绕也特别容易混淆的.于是,针对这一块,来一个分类总结吧. ...
- liunx shell数字相加
#!/bin/bash num1= num2= num3= #echo $($num1+$num2+$num3)#错误写法 echo $[$num1+$num2+$num3] echo $(($num ...
- Linux Foundation Secure Boot System Released
As promised, here is the Linux Foundation UEFI secure boot system. This was actually released to us ...
- MINA学习之IoService
从上一篇文章中知道,IoService出于MINA体系中的底层.IoService将会帮你维护网络交互,接受消息,发送消息,管理Sessions,管理连接Connections等等. IoServic ...
- Zend Framework 2参考Zend\Authentication(HTTP认证适配器)
Zend Framework 2参考Zend\Authentication(HTTP认证适配器) 介绍 Zend\Authentication\Adapter\Http提供了RFC-2617, Bas ...
- iOS使用技能 - 短信,语言验证码的获取与验证小结
最近有学习一个小技能,这里小结一下,分享给大家,互相交流. 首先是大体步骤: 在mob官网注册,然后添加短信验证的应用 使用cocoapods导入框架 Podfile文件: platform :ios ...
- Cookie案例分析
一.案例- 显示用户上次访问的时间 当用户第一次访问该页面的时候提示:你好,你是第一次访问本页面,当前时间为:2016-11-3 22:10:30 第n次访问该页面时:欢迎回来,你上次访问的时间是:2 ...
- CSharp - Comparison between IComparer and IComparable
/* Author: Jiangong SUN */ I've already written an article introducing the usage of comparer here. I ...
- VS扩展CodeMaid代码整理插件
本文章转载:http://www.cnblogs.com/wintersun/p/3577039.html 官方地址:http://www.codemaid.net/ 开源VS扩展CodeMaid介绍 ...
- 安装windows7、windows8.1提示无法创建新的分区
有时候用原版系统镜像安装windows系统时,会提示“windows无法安装到这个磁盘.选中的磁盘采用GPT分区形式”,导致安装失败,下面就来讲解一下如何解决. 1.在系统提示无法安装的那一步,按住“ ...