【问题标题】:typeerror undefined is not a function liferaytypeerror undefined 不是函数 liferay
【发布时间】:2015-03-19 15:33:30
【问题描述】:

我从服务器获取json 数据,例如1,User,2,Courses,3,Organization如下图所示的文本框(选项卡)。

,

我在alert('entities from the 466 line '+e); 中遇到了类似typeerror undefined is not a function 的异常

谁能帮帮我?

AUI().ready('aui-textboxlist', function(A) {
try {
    alert('before calling selectEntities()'); 
    var entities = selectEntities();
    console.log(" entities "+entities);
    alert("entities from the server "+entities);

    entitiesBoxList = new A.TextboxList({
        contentBox: '#<portlet:namespace />entitiesDiv',
        dataSource: entities,
        matchKey: 'name',
        schema: {
            resultFields: ['id', 'name']
        },
        queryMatchContains:true,
        queryDelimiter : ',', 
        after: {
            render: function() {
                try{
                    var instance_ = this;
                    var index = 0;
                    this.entries.insert(index, entry);
                }catch (e) {
                    alert("exception raised at 461 line"+e);
                }
            }
        }
    }).render();        
} catch(e){
    alert('entities from the 466 line '+e);
}

}

【问题讨论】:

  • 如果你用 this.entries 这样注释掉这行:// this.entries.insert(index, entry);,它还会发生吗?我能想到的另一件事是.render() 调用导致了这种情况。您的缩进非常奇怪,因此很难解释脚本,如何花一些时间重构它以使其更具可读性?您可能会在该过程中发现错误。

标签: javascript jquery liferay liferay-6 liferay-aui


【解决方案1】:

你说它与:

alert('entities from the 466 line '+e);

那么要么是说您的 alert() 不是函数(不太可能) 或者你的'e'值中的东西。既然你说它包含JSON数据,可能是因为你没有正确解析数据?

可能更好:我注意到您在第 3 行有一个名为 selectEntities() 的函数。也许它指的是该行并且您遇到了绑定问题。

【讨论】:

    【解决方案2】:

    其实上面的代码在 Liferay-6.06 中运行良好,我正在尝试将其迁移到 Liferay-6.2,所以 6.06 中的 AUI 版本在 6.2 中不起作用:

        AUI().ready('aui-textboxlist-deprecated', function (A) {
    
            // code that uses A.TextboxList goes here
        }); 
    

    代码适用于 6.2。对于 6.1,我们必须使用 aui-textboxlist 而不是 aui-textboxlist-deprecated。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-18
      • 2012-10-06
      • 2016-01-05
      • 1970-01-01
      • 2012-02-03
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多