Magento – how to implement Loader widget in magento2

jquerymagento2widgets

I want to implement loader widget in magento 2,
In my form i have placed one button

<div style="display:inline; float:right;  width:100%; margin-bottom:5px;">
    <button style="" class="scalable go" type="submit" id="button1"><span>Do some action</span></button>
</div>

When i click this button i want to call url (frontName/Controller/Action). While this action performing i want to show loader widget.

Best Answer

It's impressively simple when used inside a JS file loaded via Require JS (All/most your scripts should be so I won't go into detail about that):

 $('body').trigger('processStart');

And to remove it

$('body').trigger('processStop');

Result:

enter image description here

Related Topic