- 浏览: 680179 次
- 性别:
- 来自: 沈阳
文章分类
- 全部博客 (270)
- Ant Tool Script (12)
- XMLDigest (5)
- MyEclipse8.6 (1)
- RedHat (5)
- SVNVersionController (4)
- BatOperation (6)
- JspAndFaceWeb (66)
- javaSwing (18)
- PHP (12)
- J2SE (6)
- TestToolAndTestManual (12)
- C# (34)
- Java PatternDesign (20)
- Axis2AndWebService (5)
- ITLive (2)
- DBAndControl (10)
- C/C++ (8)
- Andriod (7)
- Python (7)
- JavaWork (16)
- Android-QA (1)
- Apache-Wicket (1)
- POI (1)
- JQuery (2)
- Struts2 (1)
- Flex&Flash (6)
- sdsdsd (0)
- 1212 (0)
最新评论
-
anayomin:
对九楼继续改进
public static <T> ...
Java List 分页 -
H4X0R:
来学习学习,赞一个
Aqua Data Studio 导出SQL -
yankai0219:
现在出现这个错误 Fatal error: Class 'PH ...
纯PHP搭建Apache+Eclipse+xDebug+PHPUnit+MakeGood -
yankai0219:
您好,我在搭建环境中提示PHPUnit_Framework_T ...
纯PHP搭建Apache+Eclipse+xDebug+PHPUnit+MakeGood -
wilsonchen:
chenhailong 写道wilsonchen 写道chen ...
C# RSA和Java RSA互通
当开发大型Extjs的项目的时候,都会遇到重复load的问题,所以我们就要就行关于这个,防止Extjs重复load
这里我提出解决方案:
/** * Script Manager class */ Ext.ux.ScriptManager = Ext.extend(Ext.util.Observable, { // The timeout in seconds to be used for requests timeout : 30, /** * @private * Array which will hold the scripts */ scripts : [], // Whether to cache the javascript files or not disableCaching : false, /** * @constructor * * Component constructor */ constructor: function(config){ Ext.apply(this, config); // Call our superclass constructor to complete construction process. Ext.ux.ScriptManager.superclass.constructor.call(this, config) }, /** * Accepts the config for loading Javascript files * @param {Object} o Config options */ loadJs : function(o){ if (!o) { return; } if (o.debug) { this.addAsScript(o); return; } if (!Ext.isArray(o.scripts)) { o.scripts = [o.scripts]; } o.url = o.scripts.shift(); if (o.scripts.length == 0) { this._loadUrl(o); } else { o.scope = this; this._loadUrl(o, function() { this.loadJs(o); }); } }, /** * Loads the css files dynamically * * @param {Object} o Config options - * {Array} scripts Array of css file paths | * {String} id Any existing css file with this id will be overwritten by the new file | * {Function} callback Function to be called once the files are loaded | * {Object} scope On this scope the callback function will be called * * @returns void */ loadCss : function(o) { var id = o.id || ''; var file; if (!Ext.isArray(o.scripts)) { o.scripts = [o.scripts]; } for (var i = 0; i < o.scripts.length; i++) { file = o.scripts[i]; id = '' + Math.floor(Math.random() * 100); Ext.util.CSS.createStyleSheet('', id); Ext.util.CSS.swapStyleSheet(id, file); } if(o.callback && Ext.isFunction(o.callback)){ o.callback.createDelegate(o.scope || window).call(); } }, /** * Adds the JS and CSS files as respective tags in DOM. This feature is used in debug:true option * @param {Object} o Config options * @returns void */ addAsScript : function(o) { var count = 0; var script; var files = o.scripts; if (!Ext.isArray(files)) { files = [files]; } var head = document.getElementsByTagName('head')[0]; Ext.each(files, function(file) { script = document.createElement('script'); script.type = 'text/javascript'; if (Ext.isFunction(o.callback)) { script.onload = script.onreadystatechange = function() { count++; if (count == files.length) { o.callback.call(); } } } script.src = file; head.appendChild(script); }); }, /** * @private * * Sends the AJAX request for loading the Javascript file * @param {String} url Url of the file to be loaded or the * config object with array of urls ans other config options * * @param {Function} callback Callback function which * will be called once all the files are loaded * * @returns Null */ _loadUrl : function(url, callback) { var cfg, callerScope; // If if (typeof url == 'object') { // must be config object cfg = url; url = cfg.url; callback = callback || cfg.callback; callerScope = cfg.scope; if (typeof cfg.timeout != 'undefined') { this.timeout = cfg.timeout; } if (typeof cfg.disableCaching != 'undefined') { this.disableCaching = cfg.disableCaching; } } // If the url exists in the scripts array, then call the callback function // This works as an recursive function call for multiple files if (this.scripts[url]) { if(callback && Ext.isFunction(callback)){ callback.createDelegate(callerScope || window).call(); } return null; } // Ajax request for loading the file Ext.Ajax.request({ url : url, success : this.processSuccess, failure : this.processFailure, scope : this, timeout : (this.timeout * 1000), disableCaching : this.disableCaching, argument : { 'url' : url, 'scope' : callerScope || window, 'callback' : callback, 'options' : cfg } }); return null; }, /** * @private * Function will be called if Ajax loading of scripts are successfull * @param {Object} response Ajax response object which will contain the script file content * @returns void */ processSuccess : function(response) { this.scripts[response.argument.url] = true; window.execScript ? window.execScript(response.responseText) : window .eval(response.responseText); if (response.argument.options.scripts.length == 0) { } if (typeof response.argument.callback == 'function') { response.argument.callback.call(response.argument.scope); } }, /** * @private * Function will be called if Ajax loading of scripts fails. It shows an error alert * @param {Object} response Ajax response object which will contain the script file content * @returns void */ processFailure : function(response) { Ext.MessageBox.show({ title : 'Application Error', msg : 'Script library could not be loaded.', closable : false, icon : Ext.MessageBox.ERROR, minWidth : 200, buttons: Ext.Msg.OK }); setTimeout(function() { Ext.MessageBox.hide(); }, 2000); } }); // Create an instance of the Script Manager ScriptMgr = new Ext.ux.ScriptManager();
使用这个的方法:
ScriptMgr.loadJs({ scripts : ['file1.js', 'file2.js'], debug : false, callback : function(){ console.log('loaded'); } });
使用这个调用CSS
ScriptMgr.loadCss({ scripts : ['path/to/file1.css', 'path/to/file2.css'] });
ScriptMgr.loadCss({ scripts : 'path/to/file1.css', id : 'file_to_be_overridden' }); ScriptMgr.loadCss({ scripts : 'path/to/file2.css', id : 'file_to_be_overridden' });
在实战中使用这个:
Ext.onReady(function(){ var panel = new Ext.Panel({ renderTo : document.body, title : 'My Panel', html: 'Hello World!', width : '100%', height : 400, tbar : [{ // A toolbar button with open window handler text : 'Open Window', scope : this, handler : function(){ ScriptMgr.loadJs({ scripts : 'LargeWindowComp.js', callback : function(){ // The window file is surely loaded now. // We can create the window instance var win = new LargeWindowComp({ width : 400, height : 300, title : 'I am loaded now' }); win.show(); } }); } }] }); });
发表评论
-
2817955743
2014-11-01 19:47 02817955743 123456789 htt ... -
JQuery的替代品Zeptojs
2014-07-30 10:24 0Zepto的小巧已经不是JQuery的可以媲美的,Zepto ... -
121212
2014-01-30 11:04 0http://metroui.org.ua/example ... -
JS 操作Cookie,记录帐号信息
2013-11-25 16:49 1434嘻嘻,今天咱整点东西,如题 主页面和JS操作,已经在 ... -
How to install two tomcat in one computer
2013-10-28 11:31 1482Today,I get a problem,show in ... -
Jackson 双引号的问题
2013-08-28 15:57 3668当用执行下面的代码的时候 String json ... -
flex
2013-06-30 19:21 0<?xml version="1.0&qu ... -
iBatis简单实践
2013-06-18 10:29 1426今天我实践了下ibatis框架,感觉也不错,很简单。嘻嘻,大 ... -
Spring的长篇大论
2013-02-07 09:06 0很长时间了,时间过的真快啊,一晃3年过去了。3年我变了很多 ... -
JQuery的Flexigrid的API使用
2013-01-16 14:21 13429JQuery Flexigrid 是一个不错的table插 ... -
bacup
2013-01-16 06:06 0我备份了,怎么没有反应啊 http://www.micr ... -
Spring MVC and AJAX with JSON
2013-01-05 14:17 27931. maven 配置 <!-- Spr ... -
JQuery ajax use json communicate with server
2013-01-05 14:12 1205好久没写文章了,我也心痒痒的,嘿嘿。现在写一篇文章。 ... -
SpringMVC wizard简单示例
2012-12-28 17:02 0public class UserController ... -
get access time from tomcat log
2012-12-25 10:14 1066下面给出我得到tomcat的Access Time的方法 ... -
JSF简单实践
2012-11-21 12:03 924希望多了,破灭的机会就会更多,所以简简单单的希望,然后实现它, ... -
Extjs Template两个小例子
2012-11-15 09:40 1452今天用Extjs Template做了两个小例子嘿 代 ... -
Tomcat Romete Debug
2012-12-25 10:14 931是我弟兄告诉我的。备忘录一下。 1,在Tom ... -
YUI
2012-10-29 15:05 0http://yuilibrary.com/forum/vie ... -
DBUnit的简单实践
2012-10-19 10:58 1355我不知道什么是失败,我也不知道失败后会是怎么样的天和地, ...
相关推荐
extjs4.0引用的JS和CSS文件,方便实用
ExtJs中Store加载(load)时候提示信息
Extjs4 表单从数据库读取数据映射到对应的字段中显示
extjs-basex.js extjs-basex.js extjs-basex.js
里面包含Extjs 2.2和Extjs 3.2.1版本两个文件
ExtJS Ext ExtJavascript Javascript
extjs4的themo库 extjs4的themo库 extjs4的themo库 Themo Library of extjs4
extjs的图标,包括相应的css,使用的时候注意路径问题
extjs-basex.js extjs-basex.js extjs-basex.js
extJS的主题皮肤 有灰色,VISTA黑,天蓝色,绿叶色,粉红,紫色.
简单的JS+CSS 仿 EXTJS GRID 表单 效果 ,IE自己稍微处理一下,
EXTJS 样式 extjs字体大小 可以轻松在这个CSS文件里面调整EXTJS插件的字体大小,对这个有需求的同志们有福了!
把皮肤文件解压 把css文件 如xtheme olive css 拷贝到extjs的resources目录下css文件夹里面:">extjs的默认皮肤很好看 但是我们还可以变换样式切换其他皮肤 1 直接添加其他css文件换肤 好多皮肤上网就可以收到的...
ExtJS(css+div+js) 未来发展的趋势,开发人员必学
extjs图表js代码
应该是目前写js和ExtJs最好的工具。 先到http://www.easyjf.com/上下载ExtJS2.0。 说明: 1,将下载的压缩包解压到eclipse的安装目录,完成后重启(自动会加载插件,也可CMD ECLIPSE目录 使用命令 eclipse -clean ...
Learn how to build powerful and professional applications by mastering the Ext JS framework Overview Build an application with Ext JS from scratch Learn expert tips and tricks to make your web ...
ExtJS 7.6 SDK trial
NULL 博文链接:https://rdman.iteye.com/blog/1156440