我的代码如下:
var cm = new Ext.grid.ColumnModel([
    new Ext.grid.RowNumberer(),
    {header:"姓名",dataIndex:'name',width:140},
    {header:"年龄",dataIndex:'age',width:100},
    {header:"年级",dataIndex:'grade'},
    {header:"操作",dataIndex:'id',renderer:function(v){return "<a href='javascript:del(" + v + ")'>删除</a>"}}
    ]);
function del(id){
  alert('测试');
}
现在的问题是:点击“删除”这个超链接的时候,没有反应,在FF中查看,老是提示说del没有定义,请问这是什么原因呀?应该怎么解决,谢谢!

解决方案 »

  1.   

    function del(id){  alert('测试'); } 写到Ext.OnReady();的外面试试看
      

  2.   

    谢谢hookee!我用的是 封装好了的单页EXTJS 系统。
    都不知道写哪儿了。
      

  3.   

    这个单独的JS框架是这样的:Ext.extend(demo.module,{
        init: function(){代码
    }
    )};
      

  4.   

    我查了些资料,看到有这种写法:<a class="x-thread-topic-link" href="#">然后
    onRowClickFn:function(grid,rowIndex,e)
    {
    var target=e.getTarget();
    var targetEl=Ext.get(target);
    var rd=this.dataStore.getAt(rowIndex);
    var id=rd.data.id;
    if(targetEl.hasClass("function-file-download"))
    {
      var url="openSourceForum/download?id="+id;
      window.open(url,"Download")
    }
    else
    {
      if(targetEl.hasClass("x-thread-topic-link"))
      {
        this.gotoTopic(rd)
      }
    }
    }好象是对应超级链接的class来写代码,没有弄明白原理。