Posted By

djbabylon on 02/03/11


Tagged

extjs SenchaTouch


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

djbabylon
enw


Extjs - Extending Component Template


 / Published in: JavaScript
 

URL: http://www.sencha.com/learn/Manual:Component:Extending_Ext_Components

  1. MyComponent = Ext.extend(Ext.some.component, {
  2. // Prototype Defaults, can be overridden by user's config object
  3. propA: 1,
  4.  
  5. initComponent: function(){
  6. // Called during component initialization
  7.  
  8. // Config object has already been applied to 'this' so properties can
  9. // be overriden here or new properties (e.g. items, tools, buttons)
  10. // can be added, eg:
  11. Ext.apply(this, {
  12. propA: 3
  13. });
  14.  
  15. // Before parent code
  16.  
  17. // Call parent (required)
  18. MyComponent.superclass.initComponent.apply(this, arguments);
  19.  
  20. // After parent code
  21. // e.g. install event handlers on rendered component
  22. },
  23.  
  24. // Override other inherited methods
  25. onRender: function(){
  26.  
  27. // Before parent code
  28.  
  29. // Call parent (required)
  30. MyComponent.superclass.onRender.apply(this, arguments);
  31.  
  32. // After parent code
  33.  
  34. }
  35. });
  36.  
  37. // register xtype to allow for lazy initialization
  38. Ext.reg('mycomponentxtype', MyComponent);

Report this snippet  

You need to login to post a comment.