简体   繁体   中英

How to catch spinning ladda buttons at the moment?

I use ladda.js in different parts of my page as following:

var siteVisitConfirmation = $('.btn-site-visit-confirmation').ladda();

siteVisitConfirmation.click(function(position) {
    siteVisitConfirmation.ladda("start");
    setSiteVisitLocation(position);
});

I have 5 ladda buttons like this. Is there any way to find out which laddaButtons are spinning?

If you need to check if a single button is spinnig, you can use the native function of the library called isLoading() :

let laddaButton = $('#mybutton').ladda();
laddaButton.ladda('start');
laddaButton.isLoading(); //true

But if you need to get multiple, then you could simple check if the button has the data-loading attribute:

let allButtonsSpinning = $('.btn-site-visit-confirmation[data-loading]');

Source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM