Good day all,
I am newby to meteor. I am having trouble to link my database to my table (handsontable). Would somebody be so kind as to scan my few lines of code and tell me where I am going wrong?
I can populate the table with a static array. However for some reason {{getData}} doesnt work in the same manner.
I have removed autopublish, insecure and added accounts-password, accounts-ui and olragon:handsontable.
Below my html (I had to change <> to () so that the html gets shown in the post)
(head
(title)Sales report(/title)
(script src=“handsontable/lib/jquery.min.js”)(/script)
(script src=“handsontable/dist/handsontable.full.js”)(/script)
(link rel=“stylesheet” media=“screen” href=“handsontable/dist/handsontable.full.css”)
(/head)
(body)
(h1)title(/h1)
{{)loginButtons}}
{{)Table}}
(/body)
(template name=“Table”)
(div class=“handsontable” id=“hot”)(/div)
(script)
var StaticData = [[‘Year’, ‘Kia’, ‘Nissan’],[‘2008’, 10, 11]];
var $container = $("#hot");
$container.handsontable({
data: StaticData // This works
//data: {{getData}} // This doesn’t work
});
(/script)
(/template)
Below my js
~~~~~~~~~~~~
VehicleSales = new Mongo.Collection('vehicles');
if(Meteor.isClient){
Meteor.call('insertSalesData', 2008, 10, 5);
Meteor.call('insertSalesData', 2009, 11, 15);
Meteor.subscribe('SalesReport');
Template.Table.helpers({
'getData':function(){ return VehicleSales.find().fetch() }
});
}
if(Meteor.isServer){
Meteor.publish('SalesReport',function(){
var currentUserId = this.userId;
return VehicleSales.find({createdBy:currentUserId},{sort: {Year:-1}});
});
Meteor.methods({
'insertSalesData':function(year,kiasales,nissansales){
var currentUserId = Meteor.userId();
VehicleSales.insert({Year:year, Kia:kiasales, Nissan:nissansales});
},
'removeSalesData':function(year_id){
VehicleSales.remove(year_id);
},
'modifySalesData':function(year_id, kiasales, nissansales){
VehicleSales.update(year_id, {$set: {Kia:kiasales,Nissan:nissansales}});
}
})
}
~~~~~~~~~~~~
Any advice will be GREATLY appreciated.
Best regards,
George