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

190
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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