2013-12-13 50 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