I’m trying to stop the default behavior of the click event handler if error happened during the execution of some Meteor method which i’m calling using Meteor.call(), the method throws an Exception if error happened, but i can’t find the right way! I tried to put Meteor.call() in a try/catch block but nothing got caught:
'click .toggle-checked' (event) {
try {
Meteor.call('tasks.setChecked', 1, !this.checked);
} catch (e) {
console.log("Error caught!");
event.preventDefault();
}
},
Also I tried to pass a callback to Meteor.call() that stops the event default behavior but it didn’t work either, it seems that the event handler finishes its work before the callback get called:
'click .toggle-checked' (event) {
Meteor.call('tasks.setChecked', 1, !this.checked, function (error, result) {
if(error) {
event.preventDefault();
console.log("error happened!", error, event);
}
});
console.log("getting out!");
},