Using a quickform like this:
{{> quickForm collection="Books" id="updateBookForm" doc=this type="method-update" meteormethod="updateBook"}}
Which then calls the updateBook method when submitted:
(This code is shared on client and server)
Meteor.methods({
insertBook: function (theBook) {
console.log('inserting book ', theBook);
Books.insert(theBook);
},
updateBook: function (modifier, id) {
console.log("updateBook method running updating these fields", modifier);
console.log("for this document id:", id);
Books.update(id, modifier);
Router.go('/');
},
});
But when updateBook is called by autoform, I get this exception on the server:
I20150427-09:40:37.530(-5)? Exception while invoking method ‘updateBook’ TypeError: Object function router(req, res, next) { // 13
I20150427-09:40:37.531(-5)? //XXX this assumes no other routers on the parent stack which we should probably fix // 14
I20150427-09:40:37.531(-5)? router.dispatch(req.url, { // 15
I20150427-09:40:37.531(-5)? request: req, // 16
I20150427-09:40:37.531(-5)? response: res // 17
I20150427-09:40:37.531(-5)? }, next); // 18
I20150427-09:40:37.531(-5)? } has no method 'go’
I20150427-09:40:37.531(-5)? at [object Object].Meteor.methods.updateBook (app/quickformdemo.js:38:14)
I have discovered that wrapping the Router.go call with Meteor.lsClient solves the issue, but I’m just wondering if I’m missing something… is this the only / best way to do this?