Good day,
I am new to meteor. I have gone through the tutorial and have hit a brick wall.
I am trying to link handsontable with meteor/mongo collection. The table does not get updated when the page is loaded, nor does the database gets updated when the table is changed.
Any advice will be greatly appreciated.
Best regards,
George
~~~~~~~~~~~~~~~
My html file
~~~~~~~~~~~~~~~~
<head>
<script src="
https://code.jquery.com/jquery.min.js"></script>
<script src="
http://handsontable.com/dist/handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="
http://handsontable.com/dist/handsontable.full.css">
</head>
<body>
<div class="handsontable" id="hot"></div>
<script>
var $container = $("#hot");
$container.handsontable({
data:
Meteor.call("GetData"), startRows: 5,
startCols: 5,
rowHeaders: true,
colHeaders: true,
minSpareRows: 1,
contextMenu: true,
afterChange: function (changes,source) { Meteor.call("AfterChange",data[changes[0][0]]._id,changes[0][1],changes[0][3]); } });
</script>
</body>
~~~~~~~~~~~~~~~~`
My .js file
~~~~~~~~~~~~~~~~
DBy = new Mongo.Collection("mydby");
DBy.insert({"Year": 2008, "Kia": 10, "Nissan": 11, "Toyota": 12, "Honda": 13 });
DBy.insert({"Year": 2009, "Kia": 20, "Nissan": 11, "Toyota": 14, "Honda": 13 });
DBy.insert({"Year": 2010, "Kia": 30, "Nissan": 15, "Toyota": 12, "Honda": 13 });
DBy.insert({"Year": 2010, "Kia": 30, "Nissan": 15, "Toyota": 12, "Honda": 13 });
if (Meteor.isClient) {}
if (Meteor.isServer) {}
Meteor.methods({
AfterChange: function(docid,field,val){ DBy.update(docid, {$set: {field: val} }); },
GetData: function(){ return DBy.find({}).fetch();}
});