pace-rails not showing for post requests

140 Views Asked by At

I have written a custom ajax function which uses POST and I need to show the pace progress bar until the ajax stops and returns. It is working fine for GET request because there is no config needed. I need to know how to set a method to show the Pace on ajax calls.

gem 'pace-rails'

Jquery for all ajax requests.

  $(document).on({
    ajaxStart: function() { Pace.start() },
    ajaxStop: function() { Pace.stop() }
  });
1

There are 1 best solutions below

0
Amal On BEST ANSWER

By default track method is set to GET we can add additional methods using these options:

<script>
    window.paceOptions = {
        ajax: {
            trackMethods: ['GET', 'POST', 'PUT', 'DELETE', 'REMOVE']
        },
        restartOnRequestAfter: true
    };
</script>