Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7061831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:31:18+00:00 2026-05-28T04:31:18+00:00

How can I both trigger and bind to an event after the page load?

  • 0

How can I both trigger and bind to an event after the page load?

The problem I am having is that in one place, on page-load I fire an event:

//producer.js
pageLoaded(){
   var e = jQuery.Event("eventA");
   $("body").trigger(e);
   ...}

and in another I bind to it:

//consumer.js
pageLoaded(){
   $("body").bind("eventA", function(args){console.log("Got it!");} );
   ... }

The problem is that the first time event is fired (when page is loaded) – the consumer does not see it. The second time event is fired, however, everything is fine!

I am guessing this is because event is actually fired BEFORE consumer starts listening to it.

Is there a good practice to follow when creating “triggers” and “listeners” to events – that have to work both on page load, and later?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:31:18+00:00Added an answer on May 28, 2026 at 4:31 am

    Using something like RequireJS will allow me to first load one javascript file, and then another.

    So I can make producer.js dependent on consumer.js

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From what I learned, a MySQL MASTER server is one that can both read
How can one trigger an event locally when a field in a connected database
Can both WPF and Windows forms controls be used within one application? How difficult
Is that possible? I mean, can both ends of the many to many relationship
I have a C#/.NET program that can run both as a console application and
We have a textbox that we want to both trigger a jQuery UI datepicker,
Unload Event can be triggered both by Refresh action and Window Close action. is
Is it possible to fire a mysql trigger for both the insert and update
My scenario is that In MVC my page(view) has both user control(partial view) and
How do I differentiate between two triggers that can both POST callbacks to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.