2013-02-15 43 views
1

我在extjs4中工作,我打算在屏幕上打印一个消息框,但它显示一个空白消息窗口。其中显示一个空白消息窗口。在extjs4 Ext.MessageBox.alert()msg disalays空白窗口?

这里是我的代码: -

Ext.application({ 
    name: 'App', 

    appFolder: 'app', 

    //controllers: ['Books'], 
    requires:[ 
       'Ext.window.MessageBox', 
       // 'Ext.tip.*' 
      ], 
    launch: function() { 
     Ext.create('Ext.tab.Panel', { 
      renderTo: Ext.getBody(), 
      height: 100, 
      width: 200, 
      items: [ 
       { 
        // Explicitly define the xtype of this Component configuration. 
        // This tells the Container (the tab panel in this case) 
        // to instantiate a Ext.panel.Panel when it deems necessary 
        xtype: 'panel', 
        title: 'Tab One', 
        html: 'The first tab', 
        listeners: { 
         render: function() { 
          //Ext.MessageBox.alert('Rendered One', 'Tab One was rendered.'); 
          Ext.Msg.alert('hi', 'Please enter your name:'); 
          //Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?'); 
          //alert("hi"); 

         } 
        } 
       }, 
       { 
        // this component configuration does not have an xtype since 'panel' is the default 
        // xtype for all Component configurations in a Container 
        title: 'Tab Two', 
        html: 'The second tab', 
        listeners: { 
         render: function() { 
          //Ext.MessageBox.alert('Rendered One', 'Tab Two was rendered.'); 
         } 
        } 
       } 
      ] 
     }); 
    } 
}); 

,这里是消息屏幕窗口

enter image description here

没有任何MessageBox的方法工作什么是错的代码? 请给我一些建议...

+0

这些链接可能会有所帮助:http://www.c4learn.com/alert-message-box-in-extjs.html和http://www.sencha.com/forum/archive/index.php/t-184113.html?s=550da2024ec35b4a06fc2e26241a9171 – cclerville 2013-02-15 07:40:14

+0

我不确定为什么当penel呈现时你显示一条消息。如果你把它放在'launch:function()'的底部,它是否可以工作那么? “Ext.MessageBox.confirm”和正常的“alert()”是否按照您的预期工作? – A1rPun 2013-02-15 08:52:23

+0

我指的是以下链接的代码http://docs.sencha.com/ext-js/4-1/#!/guide/components – 2013-02-15 09:13:36

回答

1

使用 'boxready' 事件(jsfiddle)。

如果输出到控制台:

... 
render: function() { 
    console.log(Ext.Msg.alert('hi', 'Alert message')) 
} 
.... 

在“渲染”监听器,你会看到,是计算错误警报的大小和位置:

... 
width: NaN 
x: -41 
... 
+0

它的工作原理。非常感谢。 – 2013-02-15 10:18:49

+0

+1这实际上是一个err0r的例子。 – A1rPun 2013-02-15 12:03:01