Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!