2015-01-21 152 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()的函數。也許它是指那一行,你有一個綁定問題。