Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Noty modal not closing on n.close()

The idea is to check if a certain page is available every second. When the page is available, I want to show a Noty-modal where user can choose to reload the current page or to close the modal. I use Noty.js v3.1.4.

JS Code

<script>
    var n = new Noty({
        text: "Website under construction",
        type: 'alert',
        layout: 'center',
        theme: 'bootstrap-v4',
        modal: 'true',
        buttons: [
            Noty.button("Yes", "btn btn-primary", function () {
                location.reload();
            }),
            Noty.button("No", "btn btn-primary ml-3", function () {
                checkAvailability = true;
                n.close();
            })],
        animation: {
            open: 'animated fadeIn faster',
            close: 'animated fadeOut faster'
        }
    });
    var checkAvailability = true;
    var timeout = 1000;
    
    (function(){
        if (checkAvailability) {    
            $.ajax({
                url: "https://example.com",
                type : 'HEAD',
                success : function(){
                    //website is available
                    checkAvailability = false;
                    timeout = 30000; // set timeout to 30 seconds, no need to check every second anymore
                    n.show();
                },
                error: function (){
                    //website is not available
                    checkAvailability = true;
                    timeout = 1000;
                }
            });
        }
        setTimeout(arguments.callee, timeout);
    })();
</script>

The AJAX request works and at a certain moment the Noty Modal shows up. Now when I click on 'No', the modal won't close. I see that n.closed changes from false to true, but the modal doesn't disappear. There is no log in the console. Any idea what's wrong?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda