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

158
Visualizações
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
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