Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
Loading Spinner is not Showing

So I have this Recipe Search App and whenever I'm opening new Recipe and it's loading I'm trying to add loading spinner, but for some reason it's not showing.

Here is the controller part where recipe is being loaded and renderSpinner is being called

    const controlRecipes = async function () {
  try {
    const id = window.location.hash.slice(1);
    if (!id) return;
    recipeView.renderSpinner(); // <--- Spinner Load
    //1.Loading Recipe
    await model.loadRecipe(id); //<--- Recipe Loaded
    recipeView.render(model.state.recipe);
  } catch (err) {
    recipeView.renderError();
  }
};

This is where it's being called with event listeners.

const init = function () {
  recipeView.addHandlerRender(controlRecipes);
  searchView.addHandlerSearch(controlSearchResults);
};
init();

This is the addHandler

  addHandlerRender(handler) {
    window.addEventListener('hashchange', handler);
    window.addEventListener('load', handler);
  }

And finally, this is the renderSpinner.

renderSpinner() {
const markup = `<div class="spinner">
        <svg>
          <use href="${icons}_icon-loader"></use>
        </svg>
      </div>`;
this._parentElement.innerHTML = '';
this._parentElement.insertAdjacentHTML('afterbegin', markup);


}

RenderSpinner is located not in the recipeView.js but in the View.js but I have extended recipeView to View.js and imported View.js

import View from './View.js';
class RecipeView extends View {
  _parentElement = document.querySelector('.recipe');
 

And exported view.js like this

export default class View {

So now whenever I call recipeView.renderSpinner it gets it from View.js and attributes _parentElement to the recipeView parentElement. Please help me identify why it's not loading. It was working before but after some changes in code it doesn't work and I can't understand why.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda