Guest User

Untitled

a guest
Aug 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. Ext Js - Global access to objects
  2. Ext.onReady(function()
  3. {
  4. var tabs = Ext.getCmp('dynamic-tabs');
  5. var viewport = new Ext.Viewport(
  6. {
  7. layout: 'border',
  8. renderTo: document.body,
  9. items: [
  10. {
  11. region: 'north',
  12. height: 25,
  13. xtype: 'toolbar',
  14. items: [
  15.  
  16. {
  17. xtype: 'button', text: 'Início', iconCls: 'home',
  18. handler:function() {
  19. tabs.add({
  20. title: 'Início',
  21. html: 'Tab Body',
  22. closable:true
  23. }).show();
  24. }
  25. },
  26. {
  27. xtype: 'button', text: 'Sistema', iconCls: 'sistema',
  28. menu: {
  29. items: [
  30.  
  31. {
  32. text: 'Usuários',
  33. iconCls: 'usuario',
  34. handler: function(){
  35. tabs.add({
  36. title: 'Usuários',
  37. html: 'Tab Body',
  38. closable:true,
  39. autoLoad: 'form.php'
  40. }).show();
  41. }
  42. },
  43. {
  44. text: 'Configurações',
  45. iconCls: 'sistema',
  46. handler: function(){
  47. tabs.add({
  48. title: 'Configurações',
  49. html: 'Tab Body',
  50. closable:true,
  51. autoLoad: 'form.php'
  52. }).show();
  53. }
  54. },'-',
  55. {
  56. text: 'Sair',
  57. iconCls: 'logoff',
  58. handler: function(){
  59. tabs.add({
  60. title: 'Sair',
  61. html: 'Tab Body',
  62. closable:true,
  63. autoLoad: 'form.php'
  64. }).show();
  65. }
  66. }
  67. ]
  68. }
  69. }
  70. ]
  71. }
  72. ,
  73. {
  74. region: 'center',
  75. xtype: 'tabpanel',
  76. id: 'dynamic-tabs',
  77. items: [
  78. {title: 'Início', autoLoad: 'iframe.php?url=form.php', active:true}
  79. ]
  80. }]
  81. });
  82. tabs.setActiveTab(0); // Throws: tabs is undefined
  83. });
  84.  
  85. Ext.onReady(function(){
  86. **var tabs;**
  87. var viewport = new Ext.Viewport(
  88. {
  89. layout: 'border',
  90. renderTo: document.body,
  91. items: [
  92. {
  93. region: 'north',
  94. height: 25,
  95. xtype: 'toolbar',
  96. items: [
  97.  
  98. {
  99. xtype: 'button', text: 'Início', iconCls: 'home',
  100. handler:function() {
  101. tabs.add({
  102. title: 'Início',
  103. html: 'Tab Body',
  104. closable:true
  105. }).show();
  106. }
  107. },
  108. {
  109. xtype: 'button', text: 'Sistema', iconCls: 'sistema',
  110. menu: {
  111. items: [
  112.  
  113. {
  114. text: 'Usuários',
  115. iconCls: 'usuario',
  116. handler: function(){
  117. tabs.add({
  118. title: 'Usuários',
  119. html: 'Tab Body',
  120. closable:true,
  121. autoLoad: 'form.php'
  122. }).show();
  123. }
  124. },
  125. {
  126. text: 'Configurações',
  127. iconCls: 'sistema',
  128. handler: function(){
  129. tabs.add({
  130. title: 'Configurações',
  131. html: 'Tab Body',
  132. closable:true,
  133. autoLoad: 'form.php'
  134. }).show();
  135. }
  136. },'-',
  137. {
  138. text: 'Sair',
  139. iconCls: 'logoff',
  140. handler: function(){
  141. tabs.add({
  142. title: 'Sair',
  143. html: 'Tab Body',
  144. closable:true,
  145. autoLoad: 'form.php'
  146. }).show();
  147. }
  148. }
  149. ]
  150. }
  151. }
  152. ]
  153. },{
  154. region: 'center',
  155. xtype: 'tabpanel',
  156. id: 'dynamic-tabs',
  157. items: [
  158. {title: 'Início', autoLoad: 'iframe.php?url=form.php', active:true}
  159. ],
  160. **listeners : {
  161. 'render' : function(){
  162. tabs = this;
  163. }
  164. }**
  165. }],
  166.  
  167. });
  168. tabs.setActiveTab(0); // Throws: tabs is undefined
Add Comment
Please, Sign In to add comment