2013-03-06 53 views
0

我想用ExtJS创建窗体。该文件得到妥善安置,但没有渲染正在发生的事情:ExtJs窗体渲染完全没有发生

的index.html

<html> 
<head> 
    <title>Hello Ext</title> 

    <link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css"> 
    <script type="text/javascript" src="../extjs/ext-debug.js"></script> 
    <script type="text/javascript" src="js/app.js"></script> 
</head> 
<body> 
    <div id="aa"></div> 
</body> 
</html> 

app.js

Ext.create('Ext.form.Panel', { 
    renderTo: document.getElementById('aa'), 
    title: 'User Form', 
    height: 130, 
    width: 280, 
    bodyPadding: 10, 
    defaultType: 'textfield', 
    items: [ 
     { 
      fieldLabel: 'First Name', 
      name: 'firstName' 
     }, 
     { 
      fieldLabel: 'Last Name', 
      name: 'lastName' 
     }, 
     { 
      xtype: 'datefield', 
      fieldLabel: 'Date of Birth', 
      name: 'birthDate' 
     } 
    ] 
}); 

有谁知道我缺少什么?

感谢

回答

1

在你app.js,尝试运行该代码时,onReady事件已被解雇例如

Ext.onReady(function(){ 
    Ext.create('Ext.form.Panel', { 
     renderTo: document.getElementById('aa'), 
     title: 'User Form', 
     height: 130, 
     width: 280, 
     bodyPadding: 10, 
     defaultType: 'textfield', 
     items: [ 
      { 
       fieldLabel: 'First Name', 
       name: 'firstName' 
      }, 
      { 
       fieldLabel: 'Last Name', 
       name: 'lastName' 
      }, 
      { 
       xtype: 'datefield', 
       fieldLabel: 'Date of Birth', 
       name: 'birthDate' 
      } 
     ] 
    }); 
}); 
+0

非常感谢格兰特,我想出了它 – Satya 2013-03-06 14:01:34

1

只需使用Ext.onReady()

增加一个功能,当DOM准备好被调用,所有需要 类都被加载。

如果DOM已准备好并且所有类都已加载,则立即执行传递的函数 。

工作例如:http://jsfiddle.net/Ld5e6/

+0

谢谢了很多CD。明白了,没有发射onReady() – Satya 2013-03-06 14:00:08