Javascript onClick事件不发生';我不能在Firefox中工作

Javascript onClick事件不发生';我不能在Firefox中工作,javascript,firefox,extjs,onclick,Javascript,Firefox,Extjs,Onclick,我有一个用于onClick事件的函数previewPost,但它在Firefox浏览器上不起作用。。即使在同一事件中调用单个alert(),也不起作用 <script type="text/javascript"> function previewPost() { Ext.define('WindowPost', { extend: 'Ext.window.Window', requires: [

我有一个用于onClick事件的
函数previewPost
,但它在Firefox浏览器上不起作用。。即使在同一事件中调用单个
alert()
,也不起作用

<script type="text/javascript">

 function previewPost() {
          Ext.define('WindowPost', {
              extend: 'Ext.window.Window',

              requires: [
                  'Ext.form.field.Text'
              ],

              height: 250,
              width: 400,
              title: 'My Window',

              initComponent: function() {
                  var me = this;

                  Ext.applyIf(me, {
                      items: [
                          {
                              xtype: 'textfield',
                              fieldLabel: 'ID',
                              value: this.algo
                          }
                      ]
                  });

                  me.callParent(arguments);
              }

          });
          var win = Ext.create('WindowPost',{"algo": "input"});
          win.show();
      }

       Ext.onReady(function(){

         Ext.define('DataView', {
              extend: 'Ext.view.View',
              alias: 'widget.dataview',

              requires: [
                  'Ext.XTemplate'
              ],

              id:'dataView2',
              height: 25,
              width: 1800,
              //border:true,
              emptyText: '',
              itemSelector: 'div.ticket-wrapper2',
              store:'storee2',
              initComponent: function() {
                  var me = this;

                  Ext.applyIf(me, {
                      itemTpl: [
                          '<tpl>',
                          '     <div class="ticket-wrapper2" onclick="previewPost()" >{area_comun.nombre}</div> ',
                          '</tpl>'


                      ]
                  });

                  me.callParent(arguments);
              }

          });
          var dta = Ext.create('DataView');
          dta.render('content');

});
 </script>

函数previewPost(){
Ext.define('WindowPost'{
扩展:“Ext.window.window”,
要求:[
“Ext.form.field.Text”
],
身高:250,
宽度:400,
标题:“我的窗口”,
initComponent:function(){
var me=这个;
Ext.applyIf(我{
项目:[
{
xtype:'textfield',
字段标签:“ID”,
值:this.algo
}
]
});
me.callParent(参数);
}
});
var win=Ext.create('WindowPost',{“algo”:“input”});
win.show();
}
Ext.onReady(函数(){
Ext.define('DataView'{
扩展:“Ext.view.view”,
别名:“widget.dataview”,
要求:[
“Ext.XTemplate”
],
id:'dataView2',
身高:25,
宽度:1800,
//边界:是的,
emptyText:“”,
itemSelector:'div.ticket-wrapper2',
门店:'store2',
initComponent:function(){
var me=这个;
Ext.applyIf(我{
第三方物流:[
'',
“{area_comun.nombre}”,
''
]
});
me.callParent(参数);
}
});
var dta=Ext.create('DataView');
dta.render(“内容”);
});
这里是我调用函数的地方

itemTpl: [
            '<tpl>',
            '     <div class="ticket-wrapper2" onclick="previewPost()" >{area_comun.nombre}</div> ',
                          '</tpl>'


                      ]
itemTpl:[
'',
“{area_comun.nombre}”,
''
]

onclick HTML属性非常旧,不应依赖它。相反,请为您的div提供一个id:

<div id="wrap_1" class="ticket-wrapper2">

这将适用于返回IE 9的每个浏览器。

我将该代码添加到javascript中,现在我在firebug控制台->TypeError:document中发现此错误。getElementById(…)为null@Zoolian您是否将该id添加到div?getElementById正试图用它抓住div。
document.addEventListener('DOMContentLoaded', function(){
    document.getElementById('wrap_1').addEventListener('click', previewPost);
});