Ajax Bar     

Ajax Bar is a component which displays a loading bar (like Youtube) whenever an Ajax call (regardless of Ajax library used) is in progress. It can be manually triggered as well.

Basic Usage

As long as this component is rendered by Vue it will capture all Ajax calls.

<q-ajax-bar />

Best way is to place it in your App root component (App.vue if you are using the default Quasar template):

<template>
<div id="q-app">
<router-view></router-view>
<q-ajax-bar />
</div>
</template>

IMPORTANT
Do not simultaneously use more than one Ajax Bar component in your App.

Vue Properties

Vue PropertyTypeDefault ValueDescription
positionString‘top’Where to place the loading bar: ‘top’, ‘bottom’, ‘left’ or ‘right’.
sizeString‘4px’Thickness of loading bar.
colorString‘red’One from Quasar Color Palette.
speedNumber250How fast should loading bar update its value (in milliseconds).
delayNumber1000How much should loading bar wait before showing loading bar after it’s triggered (in milliseconds).
reverseBooleanfalseReverse direction of loading bar.

Vue Methods

Only if you want to also trigger it manually. Ajax calls trigger these methods automatically.

Vue MethodDescription
start()Trigger loading bar.
stop()Notify one event has finished.

Vue Events

Vue EventDescription
@startTriggered when loading bar has been triggered to be displayed.
@stopTriggered when loading bar finished its work and goes hidden.

If multiple events are captured by Ajax Bar simultaneously, @start and @stop will still be triggered only once: when loading bar starts showing up and when it goes hidden.

How start/stop works

Each Ajax call makes a start() call when it is triggered. When it ends, it calls stop(). So yes, if you also manually trigger Ajax Bar you must call start() each time a new event is starting and stop() each time an event finished. Ajax Bar knows to handle multiple events simultaneously.