1

i Want to set loader on page load event

how can do this any idea about that?

Any help would be appreciated.

Thanks.

  • Please upload your code. – Rohan Hapani Dec 2 '19 at 3:40
  • @RohanHapani i have searching it but not found and always showing in ajax loader event – Rakesh Donga Dec 2 '19 at 3:43
0

You can use by simply way using jQuery script :

<script>
    require([
        'jquery'
    ], function ($) {
        'use strict';
        $(window).on('load', function(){
            $('body').trigger('processStart');
            $('body').trigger('processStop');
        });
    });
</script>

You can stop by below code on base of your requirement :

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

For UI Component :

require(['uiRegistry'], function (uiRegistry) {
    uiRegistry.get("customer_form.customer_form_data_source", function (element) {
        $('body').trigger('processStop'); // It will stop after ui component loaded
    })
})

Output :

enter image description here

| improve this answer | |
  • Thanks for replay i want to on page load loader widget start and after page reloading finish then stop loader – Rakesh Donga Dec 2 '19 at 3:48
  • Yes. I added code. You want to show loader like mentioned in screenshot right? – Rohan Hapani Dec 2 '19 at 3:49
  • yes correct and stop it when is page reload finishing – Rakesh Donga Dec 2 '19 at 3:54
  • You can add stop code after start code. Both will be trigger at there. – Rohan Hapani Dec 2 '19 at 3:56
  • can you upadte code ? i have no idea about that so :) – Rakesh Donga Dec 2 '19 at 3:57
0

You can try below code

<script type="text/javascript">
    require([
        'jquery',
        'loader'
    ], function ($) {
        'use strict';
        setTimeout(function(){ 
            $('body').trigger('processStart');
        }, 500);
        $(window).on('load', function(){
            console.log("page is loaded.");
            setTimeout(function(){ 
                $('body').trigger('processStop');
            }, 500);
            console.log("Stop the Loader.");
        });

    });
</script>

Hope it Helps.

| improve this answer | |
  • working your code but loader not showing up prnt.sc/q4ys83 i have use in category page – Rakesh Donga Dec 2 '19 at 10:20
  • check my updated answer. – Mohit Rane Dec 2 '19 at 10:42
  • same issue not showing loader – Rakesh Donga Dec 2 '19 at 10:50
  • I have tested this code in dashboard, it's working fine. in which file you are adding this code? – Mohit Rane Dec 2 '19 at 11:15
  • i have use in category page – Rakesh Donga Dec 2 '19 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.