Meteor show spinner on method call

734 views Asked by At

I have a button that calls a method. When the method is called, I would like to have the button change and show a spinner (inside the button itself).

I have made the button itself and the css for it.

However, I am lost in how I could hook this up with functionality to show the spinner when the method is called and stop showing it when the method returns successfully.

How can I do this? (using Template.subscriptionReady?)

1

There are 1 answers

0
Kyll On BEST ANSWER

A simple solution is to activate the spinner in the event handler and deactivate it in the method call callback once the method on the server has returned or finished:

'click #methodButton' : () => {
  activateSpinner();
  Meteor.call('some method', (err, res) => {
    if(err) throw err;
    deactivateSpinner();
  });
}