惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - EricZhen

【ExtJS实践】之七 :禁止Grid、Treegrid列排序和列菜单 【ExtJS实践】之六 :Combobox从后台获取JSON格式的数据 【ExtJS实践】之五 :常用语句及脚本备忘 【ExtJS实践】之三 :页面布局应用 【ExtJS实践】之二 :TreeGrid显示复选框 【ExtJS实践】之一 :TreeGrid异步加载数据 ASP.Net下使用ExtJS报“Ext未定义”错误的原因 关于在Windows2008里配置AjaxPro.2 【备忘】转:.net的数据库连接字符串 【备忘】转:模态窗口缓存问题的解决 【备忘】红旗Linux下安装VMWare Tools的方法 关于Cookie的一个小问题 [备忘]各类数据库连接字符串 [备忘]autorun专杀工具 [备忘].cll文件的MIME类型 [备忘]方正字库中英文对照表 [SharePoint2007]使用自定义数据库的几个问题 [SharePoint]不同页面间的多个数据视图间建立关联 C#在Word文档指定位置处理表格
【ExtJS实践】之四 :关于ExtJS的createDelegate
EricZhen · 2012-06-18 · via 博客园 - EricZhen

在学习ExtJS官网提供的CardLayout的例子时,发现了createDelegete方法。

createDelegate( Object obj, Array args, Boolean/Number appendArgs ) 是Ext中的类Function的公共方法。将官网提供的API文档翻译过来就是:

功能:创建一个委派对象(回调),该对象的作用域指向obj。对于任何函数来说都是可以直接调用的。

参数项:
obj : Object
(可选的) 自定义的作用域对象。
args : Array
(可选的) 覆盖该次调用的参数列表。(默认为该函数的arguments)。

appendArgs : Boolean/Number
(可选的) 如果该参数为true,将args加载到该函数的后面,如果该参数为数字类型,则args将插入到所指定的位置。

 
返回值:
Function
新产生的函数。

为了更好的理解它的使用方法,我从网上引用了一个例子(原帖地址):

View Code

 1 Ext.onReady(function(){ 
 2   Ext.QuickTips.init() 
 3   var myclass=new Object(); 
 4   //myclass并没有alert方法,我们也不打算为它写一个alert方法 
 5   //我们希望它和window.alert有一样的行为,所以我们委托window来做  
 6   myclass.alert=window.alert.createDelegate(window); 
 7   //我们还希望他有个更漂亮的show方法和Ext.MessageBox的show功能一样 
 8   //所以我们又得委托给Ext.MessageBox来做这事了
 9   myclass.show=Ext.MessageBox.show.createDelegate(Ext.MessageBox); 
10   //我们的myclass也有alert和show方法了 
11   myclass.alert('alert1'); 
12   myclass.show({title:'title',msg:'message'}); 
13 });