2015-07-22 94 views
0

我正在使用Magento ver。 1.9.1.1。當前端用戶登錄時,它給這個js錯誤。Magento用戶登錄後獲取錯誤

TypeError: $link.attr(...) is undefined

和很少的功能停止工作我認爲通過js庫來的東西正在成爲問題。它對於匿名用戶來說工作正常意味着沒有前端用戶登錄。是否有人熟悉或面臨相關問題。可以幫助

回答

1

我的所有解決方案都基於假設,因爲問題並不清楚。

1]看來你的js與其他js衝突。根據我更新1.6以上的jquery。它可能解決你的問題。 http://api.jquery.com/attr/

As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. To retrieve and change DOM properties such as the checked, selected, or disabled state of form elements, use the .prop() method.

2]在您的jQuery文件的末尾將jQuery.noConflict();

3]如果您的自定義js中發生錯誤。因爲您尚未發佈出現錯誤的文件或代碼。所以根據我所搜索的屬性並沒有設置在你正在搜索的元素上。由於這個原因,.replace失敗,因爲undefined沒有替換方法。你需要確保它不是第一個未定義的。

var attribute = $(this).attr('rel'); //Maybe you're getting error here. Change it like this. 
attribute = attribute ? attribute.replace('attributeremove_', '') : ''; 
+0

jquery.nav.js中出現錯誤我使用了新主題。我試着用你建議的方式更新jquery到你問的版本,並且把jQuery.noConflict();但沒有區別。它爲匿名用戶工作正常。用戶登錄後有什麼不同? – varinder