/ext-4.0.7/docs/guides/components/examples/lazy_instantiation/app.js

https://bitbucket.org/srogerf/javascript · JavaScript · 42 lines · 30 code · 2 blank · 10 comment · 0 complexity · 72ed10a7be75a75baba56d1e9dc78f1d MD5 · raw file

  1. /**
  2. * @example Lazy Instantiation
  3. *
  4. * A basic example demonstrating how a Container contains other items using the items config.
  5. */
  6. Ext.require('Ext.tab.Panel');
  7. Ext.require('Ext.window.MessageBox');
  8. Ext.onReady(function() {
  9. Ext.create('Ext.tab.Panel', {
  10. renderTo: Ext.getBody(),
  11. height: 100,
  12. width: 200,
  13. items: [
  14. {
  15. // Explicitly define the xtype of this Component configuration.
  16. // This tells the Container (the tab panel in this case)
  17. // to instantiate a Ext.panel.Panel when it deems necessary
  18. xtype: 'panel',
  19. title: 'Tab One',
  20. html: 'The first tab',
  21. listeners: {
  22. render: function() {
  23. Ext.MessageBox.alert('Rendered One', 'Tab One was rendered.');
  24. }
  25. }
  26. },
  27. {
  28. // this component configuration does not have an xtype since 'panel' is the default
  29. // xtype for all Component configurations in a Container
  30. title: 'Tab Two',
  31. html: 'The second tab',
  32. listeners: {
  33. render: function() {
  34. Ext.MessageBox.alert('Rendered One', 'Tab Two was rendered.');
  35. }
  36. }
  37. }
  38. ]
  39. });
  40. });