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

195
Visualizações
jQuery .trigger() isn't being caught

Does jQuery .trigger() or .triggerHandler() work across two separate JavaScript files? I have a timeline that when interacted with, triggers a function

scrubbingToTime(position). In a separate JavaScript file, I want to detect when scrubbingToTime(position) is being called, so I was looking into jQuery .trigger(). The code is hard to reproduce, but the idea was that it was like:

timeline.js

function scrubbingToTime(position) {
     $(document).trigger("scrub", [position]);
}

catch.js

$(document).on("scrub", function(e, pos) {
     console.log("Time Changed!");
});

This does not work, however if the trigger and on are in the same file, it works fine. For example,

timeline.js

function scrubbingToTime(position) {
     $(document).trigger("scrub", [position]);

     $(document).on("scrub", function(e, pos) {
           console.log("Time Changed!");
     });
}

This actually console.logs the Time Changed! message. Is there any reason why the first (what I want) won't work?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to make sure the order of the JS loading is correct.

If you are loading your catch.js file first, then timeline.js won't know about scrub because it hasn't been loaded yet.

about 4 years ago · Juan Pablo Isaza Relatório
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