2014-02-07 40 views
0

我是新來的sencha touch。我面臨的問題,這是我的第一個測試應用程序。確認框未正確呈現

Ext.Msg.confirm('', 'Are you sure you want to reset this form?', function (btn) { 
        if (btn === 'yes') { 
        } 
       }); 

問題出在確認框樣式。它的到來,但它不適合。 這裏是連接屏幕截圖 enter image description here

這是我使用的代碼

BillingForm.js

Ext.define("test.view.BillingForm", { 
    extend: "Ext.Container", 
    config: { 
    items: [{ 
     title: "Basic", 
     xtype: "formpanel", 
     id: "billingForm", 
     items: [ 
      { 
      xtype: "fieldset", 
      title: "Billing Information", 
      defaults: { 
       labelWidth: "32%", 
       style: { 
       "background-color": "#fff", 
       "font-size": "12px", 
       "color": "#333" 

       } 
      }, 
      items: [ 
       { 
       xtype: 'textfield', 
       name: 'firstname', 
       label: 'First Name', 
       palceholder: "Enter your first name", 
       required: true, 
       focus: true 

       } 
      ] 
      }, 
      { 
      xtype: 'button', 
      text: 'Reset', 
      ui: 'decline', 
      handler: function(btn, evt) { 
       Ext.Msg.confirm('', 'Are you sure you want to reset this form?', function (btn) { 
        if (btn === 'yes') { 
        } 
       }); 
      } 
      } 
     ] 
     } 
    ] 
    } 
}); 

MainView.js

Ext.define('test.view.MainView', { 
    extend : "Ext.Container", 
    alias : ["widget.mainview"], 
    config: { 
     fullscreen: true, 
     layout: { 
      type: "vbox" 
     }, 
     items: [{ 
      xtype: "toolbar", 
      docked: "top", 
      height: 45, 
      title: "First App" 
     }, 
     Ext.create("test.view.BillingForm",{ 
      height:300, 
      padding:"10 0 0 0" 
     }) 

     ], 
    } 
}); 

app.js

Ext.onReady(function(){ 
    Ext.application({ 
     name: 'test', 
     appFolder : 'app', 
     models : [], 
     stores : [], 
     requires: [], 
     views: ["MainView","BillingForm"], 
     controllers: [], 
     isIconPrecomposed : true, 
     profiles : [], 
     launch: function() { 
      Ext.create("test.view.BillingForm", {}); 
     } 
    }); 
}); 

的Index.html

<!DOCTYPE> 

<html lang="en"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <title>Hello World</title> 
    <link href="http://localhost/projects/touch/resources/css/cupertino.css" type="text/css" rel="stylesheet"/> 
    <script src="http://localhost/projects/touch/sencha-touch-all-debug.js"></script> 
    <script src="app.js"></script> 
</head> 
<body> 
</body> 
</html> 

回答

0

你的代碼中有很多問題。下面是我可以通過一瞥您的代碼而看到的問題列表:

  1. 當您使用Ext.application函數時,您不需要Ext.onReady。只要刪除它。
  2. 在啓動函數中,創建MainView而不是BillingForm
  3. 在MainView中添加BillingForm是錯誤的。提供的xtype:在BillingForm定義「billingform」略低於延長:「Ext.Container」,然後在的MainView的項目,而不是創建新BillingForm,只要加入這樣的:

    items: [{ 
        xtype: "toolbar", 
        docked: "top", 
        height: 45, 
        title: "First App" 
    },{ 
        xtype:'billingform' 
    }] 
    

糾正這些,然後看看它是否有幫助。