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

165
Views
get event source that triggers events on other elements

In a ASPX MVC view, I use TypeScript to control the client interaction. Some elements' change event could trigger a sequence of other elements' change events. In each of the other element's change() I need to check if it is triggered by the element itself, or preceding element, or by the very first element that fires the event chain. In this example, it is Q12 or Q23, or both. Thanks.

const Q12: any = $('.persistable[id^=Q12_]');
const Q23: any = $('.persistable[id^=Q23_]');
const otherPersistables: any = $('.persistable:not([id^=Q12_]):not([id^=Q23_])');

if (commonUtility.isEmpty(Q12) || commonUtility.isEmpty(Q23)) {
  otherPersistables.each(
    function() {
      //disable this element and trigger it change() event
      $(this).prop('disabled', ture).change();
    }
  );
} else {
  otherPersistables.each(
    function() {
      //enable this element and trigger its change() event
      $(this).prop('disabled', false).change();
    }
  );
}

//add event listener to each of the other persistable elements
otherPersistables.each(
  const thisOtherElment = $(this); 
  thisOtherElment.on("change",
    function() {
     //how to check what really initiates this change if not by this element
     //for example, it could be Q23 or Q12, or both
    }
  }
);

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