2012-04-10 43 views
0

有人可以說我爲什麼「getEl()」方法在我的代碼中不起作用嗎?方法getEl()不起作用

NotificationContainer:

Ext.define('common.NotificationContainer', { 
    extend: 'Ext.container.Container', 
    alias: 'widget.NotificationContainer', 
    border: true, 
    layout: { 
     type:'fit' 
    }, 
    style: { 
     zIndex: '999999' 
    }, 
    defaultType: 'container', 
    items: [{ 
     cls: 'notification-box', 
     border: true, 
     width: 500, 
     items:[{ 
      html: '' 
     },{ 
      layout: { 
       type: 'vbox', 
       align: 'center' 
      }, 
      items: [{ 
       xtype: 'button', 
       text: 'OK', 
       minWidth: 75, 
       margin: '10 0 0 0', 
       handler: function() { 
        this.up().up().up().getEl().slideOut('t', { duration: 1000 }); 
       } 
      }] 
     }] 
    }] 
}); 

功能:

var con_notification = Ext.create('common.NotificationContainer'); 
var con_notification_box = con_notification.child(); 

con_notification_box.addCls(cls); 
if (server_response == undefined) { 
    con_notification_box.items.items[0].update('<p><span class="custom-msg">' + custom_msg + '</span></p>'); 
} else { 
    con_notification_box.items.items[0].update('<p><span class="custom-msg"> ' + custom_msg + '</span><br /><br /><span class="server-response">Server Response:</span>' + server_response + '</p>') 
} 

con_notification.add(con_notification_box); 
con_notification.getEl().slideIn('t', { 
    easing: 'easeOut', 
    duration: 1000 
}); 

非常感謝您的支持!

親切的問候,SHUB

+0

你是什麼意思**不工作**?記錄的錯誤是什麼? – 2012-04-10 18:17:37

+0

該方法返回始終未定義。因此「slideIn」方法也不起作用。 – shub 2012-04-10 18:22:52

+0

只在這一行'con_notification.getEl()。slideIn'?上面帶有slideOut的'getEl()'可以工作,對嗎? – 2012-04-10 18:28:04

回答

7

這是相當難以從這樣的一些代碼inpect錯誤,但有一個事實是,當你的組件呈現getEl()只返回一個有效的元素。

希望它有幫助。