2012-02-22 23 views
2

當加載到Ember的初始化流程的相同頁面中的prototype.js被破壞,並且內部Ember對象(應用程序,視圖等)未定義時。在https://github.com/eishay/starter-kit無法在prototype.js頁面中運行Ember.js

Uncaught TypeError: Object #<Object> has no method 'each' 
collect prototype.js:864 
init Mixinember-0.9.5.js:5927 
Mixin.create ember-0.9.5.js:6175 
get ember-0.9.5.js:6394 
(anonymous function) 

隨着ember.min 見樣本項目:

Enumerable.collect() at prototype.js:485 
n() at ember-0.9.5.min.js:10 
b.create() at ember-0.9.5.min.js:10 
(anonymous function)() at ember-0.9.5.min.js:10 
(anonymous function)() at ember-0.9.5.min.js:10 

編輯: 剛纔看到一個線程討論它在https://github.com/emberjs/ember.js/issues/453沒有解決

回答

3

如果你能得到灰燼。 js在原型之前加載,你會得到解決。

其他東西看起來確實有問題,Ember.js廣泛使用map(),prototype.js似乎很高興地用它自己的實現(collect())覆蓋它。

修補原型非常簡單,只需將(例如).map替換爲_map以使其發揮更好,有點我明白這在您的情況下是不存在的。

對於它的價值,這裏是更新後原型: https://github.com/AvnerCohen/Prototype.js-map-patched

注意,有些事情現在在prototype.js中1.7改變,但這個問題仍然存在..

+0

謝謝,但我將我的JavaScript應用嵌入到我無法控制的託管頁面中。當我用array.prototype解決了這個問題時,其他人也出現了。我想我將無法使用餘燼。 https://github.com/emberjs/ember.js/issues/453#issuecomment-4111293 – 2012-02-22 18:01:25

+0

Ember有一個禁用的原型開關,它可以使用javascript內建對象(數組,字符串,函數)或庫修改這些:http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/ – Szabi 2013-04-06 20:21:00

+0

@ Jar.Jar.beans,你現在是我的英雄。 – Beez 2013-11-15 21:39:09