ExtJS笔记--applyTo和renderTo的差别
extjs中常常会用到renderTo或applyTo配置选项。这里,我就比較下两者的差别与使用方法。
1、renderTo与render方法相应
2、applyTo与applyToMarkup方法相应
一、applyTo的使用:
1、applyTo所指向的el元素必需要有父节点。
2、applyTo所指向的el元素实际上是充当了对象要渲染的模板,对象是渲染在其父节点内。即对象实例化后所产生的html代码是插入在el元素的父节点内,而el元素本身将仅仅作为模板,并不作为真正的在其位置上的元素,既然作为模板,仅仅是利用其标签内的部分style和class,就不应该包括子节点(包括文本)。
3、这个作为模板的el元素非常重要,必须是要存在的。
4、演示样例代码:
Html代码
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>applyTo与renderTo的差别</title>
6 <link rel="stylesheet" type="text/css" href="../scripts/ext/resources/css/ext-all.css"/>
7 <script type="text/javascript" src="../scripts/ext/adapter/ext/ext-base.js"></script>
8 <script type="text/javascript" src="../scripts/ext/ext-all.js"></script>
9 <script type="text/javascript">
10 Ext.onReady(function(){
11 var _panel = new Ext.Panel({
12 title:"个人信息",
13 width:300,
14 height:300,
15 frame:true,
16 applyTo:"appConId"
17 });
18 });
19 </script>
20 </head>
21 <body>
22 <div id="appId" style="padding:30px;width:500px;height:400px;background-color: blue;">
23 <div id="appConId" style="width:400px;height:400px;background-color:green;"></div>
24 </div>
25 </body>
26 </html>
<!--EndFragment-->

二、renderTo的使用:
1、能够有el配置选项。
2、假设有el配置选项,则其指向的el元素充当了模板,而且必须存在。
3、renderTo所指向的el元素将作为对象渲染的入口,即render所产生的html代码将作为renderTo所指向的el元素的子节点。
4、假设有el配置选项,那么render会将el配置选项所指向的el元素作为模板然后产生html代码作为renderTo所指向的el元素的子节点。
5、演示样例代码:
Html代码
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>applyTo与renderTo的差别</title>
6 <link rel="stylesheet" type="text/css" href="../scripts/ext/resources/css/ext-all.css"/>
7 <script type="text/javascript" src="../scripts/ext/adapter/ext/ext-base.js"></script>
8 <script type="text/javascript" src="../scripts/ext/ext-all.js"></script>
9 <script type="text/javascript">
10 Ext.onReady(function(){
11 var _panel = new Ext.Panel({
12 title:"个人信息",
13 width:300,
14 height:300,
15 frame:true,
16 el:"elId",
17 renderTo:"appConId"
18 });
19 });
20 </script>
21 </head>
22 <body>
23 <div id="appId" style="padding:30px;width:500px;height:400px;background-color: blue;">
24 <div id="appConId" style="width:400px;height:400px;background-color:green;"></div>
25 </div>
26 <div id="elId" style="width:500px;height:400px;background-color:red;">
27 </div>
28 </body>
29 </html>

ExtJS笔记--applyTo和renderTo的差别的更多相关文章
- extjs笔记
1. ExtJs 结构树.. 2 2. 对ExtJs的态度.. 3 3. Ext.form概述.. 4 4. Ext.TabPanel篇.. 5 5. Functio ...
- ExtJS笔记 Tree
The Tree Panel Component is one of the most versatile Components in Ext JS and is an excellent tool ...
- ExtJS笔记 Using Events
Using Events The Components and Classes of Ext JS fire a broad range of events at various points in ...
- ExtJS笔记5 Components
参考 :http://blog.csdn.net/zhangxin09/article/details/6914882 An Ext JS application's UI is made up of ...
- ExtJS笔记 Grids
参考:http://blog.csdn.net/zhangxin09/article/details/6885175 The Grid Panel is one of the centerpieces ...
- ExtJS笔记 Form
A Form Panel is nothing more than a basic Panel with form handling abilities added. Form Panels can ...
- ExtJS笔记4 容器与布局(Layouts and Containers)
The layout system is one of the most powerful parts of Ext JS. It handles the sizing and positioning ...
- ExtJS笔记3 MVC Architecture
MVC Architecture MVC架构 Contents File Structure Creating the application in app.js Defining a Contr ...
- ExtJs4学习(四):Extjs 中id与itemId的差别
为了方便表示或是指定一个组件的名称,我们一般会使用id或者itemId进行标识命名. (推荐尽量使用itemId.这样能够降低页面唯一标识而产生的冲突) id: id是作为整个页面的Comp ...
随机推荐
- 双系统格式化硬盘后装XP遇到grub rescue的问题
好奇于深度的Deepin系统,给老电脑装了xp和deepin双系统.无奈07年的机子带Deepin,实在是太卡了.正好想给硬盘重新分区,直接将硬盘格式化,重装了xp.于是,问题来了,开机显示: GRU ...
- Python+django部署(一)
之所以 写这篇文章的原因在于django环境的确轻松搭建,之前Ubuntu上安装了,的确很轻松,但是后期我才知道随便做个环境出来很容易到了后面很麻烦,污 染了系统里的python版本,导致系统pyth ...
- Android Environment 判断sd卡是否挂载 获取sd卡目录
在将一个文件存储到sd卡上面的时候,一般需要判断sd是否已经挂载才进行操作. 那么如何判断sd卡已经挂载呢? 我们可以使用Android的Environment类,具体使用如下: if(Environ ...
- duilib入门简明教程 -- VS环境配置(2) Alberl
既然是入门教程,那当然得基础点,因为搜索duilib相关资料时,发现有些小伙伴到处都是编译错误,以及路径配置错误等等,还有人不知道SVN,然后一个个文件手动下载的. 其实吧,duilib的 ...
- reviewboard搭建
reviewboard的搭建 系统:fedora 19 内核版本:3.9.5-301.fc19.x86_64 步骤 命令 备注 安装mysql # yum -y install mysql mysql ...
- android Button 颜色的变化(点击,放开,点击不放)
参考: http://endual.iteye.com/blog/1534258 总结: 定义res/drawable/button_style.xml文件 <?xml version=&quo ...
- 在windows下解压缩Linux内核源代码出现重复文件原因
在windows下解压缩Linux内核源代码出现重复文件原因 2009年06月30日 13:35 来源:ChinaUnix博客 作者:embededgood 编辑:周荣茂 原因一.因为在Lin ...
- CSS3实现的player播放按钮
完成的效果如下 查看效果并下载 Step 1:先了解border的原理: Step 2:HTML代码结构 <section class="playContainer"> ...
- Beta Round #9 (酱油杯noi考后欢乐赛)PLQ的寻宝
题目:http://www.contesthunter.org/contest/Beta%20Round%20%EF%BC%839%20%28%E9%85%B1%E6%B2%B9%E6%9D%AFno ...
- 用vmware安装gho文件
方法1:diskgenius+ghostexp 用vm新建一个空白硬盘虚拟机, 记住虚拟机文件的存储位置, 最好将默认的scsi硬盘移除另外新建ide的硬盘(否则可能开机蓝屏),然后用host机DIS ...