2013-03-13 91 views
0

我正在创建下面的表单,但出于某种原因,选择按钮处理程序不会执行 。其他一切正常工作(将数据加载到网格中)。 有什么我失踪了吗?ExtJS按钮不执行处理程序

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

Ext.define('Project', { 
    extend: 'Ext.data.Model', 
    fields: ['PID', 'ProjectName'] 
}); 

var projectsStore = Ext.create('Ext.data.Store', 
{ 
    model: 'Project', 
    autoLoad: true, 
    proxy:{ 
     type: 'ajax', 
     url : 'projects.php?action=read', 
     reader:{ type:'json', root:'projects', successProperty:'success' } } 
}); 

Ext.onReady(
    function() 
    { 
     var simple = Ext.create('Ext.form.Panel', { 
     url:'projects.php?action=select', 
     frame:true, 
     title: 'Projects', 
     bodyStyle:'padding:5px 5px 0', 
     width: 350, 
     fieldDefaults: { 
      msgTarget: 'side', 
      labelWidth: 75 
     }, 
     defaultType: 'textfield', 
     defaults: { 
      anchor: '100%' 
     }, 

     items: [{ 
      columnWidth: 0.60, 
     xtype: 'gridpanel', 
     store: projectsStore, 
     height: 400, 
     title:'General', 
     columns: [ 
     {header: 'Id', dataIndex: 'PID', flex: 1}, 
     {header: 'Project Name', dataIndex: 'ProjectName', flex: 1}, 
     ] 
     }], 

     buttons: [{ 
      text: 'Select', 
      handler: function() { 
       Ext.Msg.alert('Selecting', action.result.msg);    
      } 
     }] 
    }); 

    simple.render('proj-form'); 

     projectsStore.load(); 
    } 
); 

回答

1

您的代码在运行处理程序时崩溃,因为action.result.msg不存在。

你可以看看Firebug/Chrome开发工具,它会告诉你的问题。

+0

我没有看到萤火虫的错误。你看什么标签? – 2013-03-13 03:00:12