Extjs学习笔记之五 一个小细节renderTo和applyTo的区别

  render : function(container, position){

  if(!this.rendered && this.fireEvent('beforerender', this) !== false){

  if(!container && this.el){

  this.el = Ext.get(this.el);

  container = this.el.dom.parentNode;

  this.allowDomMove = false;

  }

  this.container = Ext.get(container);

  if(this.ctCls){

  this.container.addClass(this.ctCls);

  }

  this.rendered = true;

  if(position !== undefined){

  if(Ext.isNumber(position)){

  position = this.container.dom.childNodes[position];

  }else{

  position = Ext.getDom(position);

  }

  }

  this.onRender(this.container, position || null);

  if(this.autoShow){

  this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);

  }

  if(this.cls){

  this.el.addClass(this.cls);

  delete this.cls;

  }

  if(this.style){

  this.el.applyStyles(this.style);

  delete this.style;

  }

  if(this.overCls){

  this.el.addClassOnOver(this.overCls);

  }

  this.fireEvent('render', this);

  var contentTarget = this.getContentTarget();

  if (this.html){

  contentTarget.update(Ext.DomHelper.markup(this.html));

  delete this.html;

  }

  if (this.contentEl){

  var ce = Ext.getDom(this.contentEl);

  Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);

  contentTarget.appendChild(ce);

  }

  if (this.tpl) {

  if (!this.tpl.compile) {

  this.tpl = new Ext.XTemplate(this.tpl);

  }

  if (this.data) {

  this.tpl[this.tplWriteMode](contentTarget, this.data);

  delete this.data;

  }

  }

  this.afterRender(this.container);

  if(this.hidden){

  this.doHide();

  }

  if(this.disabled){

  this.disable(true);

  }

  if(this.stateful !== false){

  this.initStateEvents();

  }

  this.fireEvent('afterrender', this);

  }

  return this;

  }