2015-01-21 153 views
0

我正在从服务器上获取json数据,如1,User,2,Courses,3,Organization正确,我将这些数据存储在一个变量实体中,现在我将这个json数据添加到文本字段中用于自动完成,然后允许多个文本框(标签)的值如下图所示。typeerror undefined不是函数liferay

enter image description here

我越来越喜欢在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); 
} 

} 
+1

如果你注释掉this.entries这样的行:'// this.entries.insert(index,entry);',它还会发生吗?我能想到的另一件事是'.render()'调用正在导致这一点。你的缩进是非常奇怪的,所以很难解释这个脚本,花些时间重构它使它更具可读性。您可能会在该过程中发现错误。 – Nenotlep 2015-01-21 07:37:31

回答

0

其实上面的代码中的Liferay-6.06工作正常,我试图将其迁移到Liferay-6.2,所以AUI版本6.06不工作在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。

1

你说是在与线:

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

然后它或者说您的警报()不是(不太可能) 或东西在你的“E”值的函数。既然你说它包含JSON数据,可能是因为你没有正确解析数据?

可能更好:我注意到你在第3行有一个叫做selectEntities()的函数。也许它是指那一行,你有一个绑定问题。