2013-12-13 48 views
1

我已經從大氣中安裝了Handsontable軟件包,並且除了當我嘗試創建自定義單元格渲染器時,定義表格在我的應用程序中正常工作。流星錯誤,未定義Handsontable

在定義表中的問題的代碼是此列的定義:

{ 
    type: { 
    renderer: function(instance, td, row, col, prop, value, cellProperties) { 
     Handsontable.TextCell.renderer.apply(this, arguments); 
     $(td).css({ 
     background: 'yellow' 
     }); 
    }}, 
    //format: '0, 0.00 $', 
    readOnly: true 
    } 

每當我試圖使像上面的Handsontable.Textcell.renderer.apply一個Hansontable電話,流星引發此錯誤:

Exception from Deps afterFlush function: ReferenceError: Handsontable is not defined

我讀過Handsontable使用Jquery 1.9,但Meteor與1.8捆綁在一起。這可能是一個問題嗎?

我在Handsontable中看到的自定義單元格渲染器的每個示例與我所看到的類似,所以我對這個問題非常迷茫。我還用最新版本創建了一個Handsontable自定義包,但這也沒有幫助。

想得到任何幫助。謝謝!

回答

1

這可能是Handsontable包中的一個錯誤。

這條線:https://github.com/olragon/meteor-handsontable/blob/master/lib/jquery.handsontable.full.js#L13

var Handsontable = { 

應該

Handsontable = { 

在流星文件是可變的作用域。如果您使用var關鍵字,則其他文件無法訪問它。這是你得到的Handsontable is not defined錯誤

您還可以通過添加以下後https://github.com/olragon/meteor-handsontable/blob/master/package.js#L6

api.export("Handsontable"); 

從而使API暴露出來的包線導出它的原因之一。

我已經提出了一個拉請求,所以包維護者需要接受它並更新包裝上的氣氛,然後你可以運行mrt update並使用你的代碼,就像你現在使用的那樣。

如果你很着急,你可以用叉的更新包,並使用它作爲您的Handsontable

https://github.com/olragon/meteor-handsontable/pull/1

+0

驚人的回答,非常感謝你! – rickydav