2011-11-23 122 views
0

我正在使用sencha touch 2 PR1。當我點擊警報按鈕時,打開的警報框沒有「確定」按鈕,其高度覆蓋整個頁面。 這裏是我的看法'確定'按鈕不顯示在Ext.Msg.alert

Ext.define('MyTask.view.Main', { 
extend: 'Ext.Container', 
alias: 'widget.main', 
config: { 
    items: [ 

     { 
      xtype : 'button', 
      cls : 'demobtn', 
     ui : 'round', 
     margin: '10 0', 
     text: 'Alert', 
      handler: function() { 
      Ext.Viewport.add(Ext.Msg); 
       Ext.Msg.alert('Title', 'The quick brown fox jumped over the lazy dog.',  Ext.emptyFn); 
      } 
     } 

    ] 
} 
}); 

和控制器

Ext.define('MyTask.controller.TestController', { 
extend: 'Ext.app.Controller', 
views: ['Main'], 
refs: [ 
    { 
     ref  : 'main', 
     selector: 'main', 
     autoCreate: true, 
     xtype : 'main' 
    }, 

], 

init: function() { 
mainPanel=this.getMain(); 
Ext.Viewport.add(mainPanel); 

} 

}); 

和app.js

Ext.Loader.setConfig({ enabled: true }); 


Ext.require([  
'Ext.XTemplate', 
'Ext.Panel', 
'Ext.Button', 
'Ext.List', 
'Ext.MessageBox' 
]); 




Ext.application({ 

name: 'MyTask', 
controllers: ['TestController'], 

}); 

爲什麼沒有得到正常顯示呢?我在crome和ipad上測試過。 在此先感謝。

回答

2

爲什麼要將Ext.Msg添加到視口。更改處理程序的功能如下

handler: function() { 

       Ext.Msg.alert('Title', 'The quick brown fox jumped over the lazy dog.',  Ext.emptyFn); 
      } 

即除去Ext.Viewport.add(Ext.Msg);

注:我測試了煎茶1.1.0

希望這將有助於...

+0

贏了,沒什麼影響。我將它添加到視口中,因爲它給出了必須在視口中添加的警告 – Anagha

+0

它不起作用。 – Khush

+0

Hi @Khush,它在我的應用程序中工作(建立在sencha 1.1.0上)。讓我用sencha 2.0.0來檢查它。我也會編輯我的答案。 – heyjii

1

我得到了同樣的問題,即使有煎茶觸摸版本2.0.0。

在第一次,我認爲這是一個Sencha Touch的錯誤。 經過幾天的研究,我發現了這個bug的根源。 我在HTML5 <!DOCTYPE html>聲明之前在HTML頁面中添加了一個額外的標記。 我通過將HTML5聲明<!DOCTYPE html>放在我的頁面的最上方來糾正它,它解決了我的問題。

1

嗨下面的代碼會幫助你解決你的問題: -

上煎茶觸摸2.0最終測試的代碼。

Ext.Msg.show({ 
       title: 'Title', 
       message: 'The quick brown fox jumped over the lazy dog.', 
       buttons: [{ 
          id: 'alertCancelBtn', 
          iconCls: 'user', 
          iconMask: true, 
          text: 'Ok', 
          ui: 'round decline' 
          }], // buttons 
       height: 200, 
       width: 150, 
        // Ext.emptyFn  
    }); // show()