Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to prevent the loadingTemplate from showing up on "fast" routes?

Most of the time, my search returns so fast that it's not worth flashing the loading template to the user...(in fact, it's distracting, as people are fine with a blank screen if the results are coming a split second later)...Is there any way to prevent the loading template from showing if the waitOn is only waiting for a short amount of time?

Here's my configuration

  Router.route('/search', {
    waitOn: function () {
      return searchSubsManager.subscribe("search", Session.get('searchString'));
    },
    action: function () {
      this.render('searchResults');
    }
  });

I saw that with this package: https://github.com/Multiply/iron-router-progress you can control whether it shows up for fast routes, but I don't need all that functionality, nor do I want the progress bar it provides... I'm just wondering if the basic iron router/ waitOn functionality can provide this ability.

like image 604
Wes Avatar asked Dec 07 '25 07:12

Wes


1 Answers

There is not configuration to use on the waitOn function, but Why don't you create another layout template, and use it to show that fast routes?

<template name="noLoading">
  {{> yield}}
</template>

Router.map(function () {
  this.route('fastRoutes', {
  path: '/someRoutes',
  template: 'myHomeTemplate',
  layoutTemplate: 'noLoading',
  });
});

Update

or use the sacha:spin package and change the class name depending on the duration of the query.

if(queryDuration){
 Meteor.Spinner.options = {
    className: 'none'
  }
}else{
  Meteor.Spinner.options = {
    className: 'spinner'
  }
}
like image 68
Ethaan Avatar answered Dec 09 '25 21:12

Ethaan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!