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

145
Visualizações
Trigger event (e.g. via jQuery) when handler accesses originalEvent

I'm trying to trigger the propertychange event on an input field for a bookmarklet (the field is OpenGrok's search field).

The handler for that field is defined like this (this is the de-minified OpenGrok source):

function(i) {
  var h = true;
  if (i.type == "propertychange") {
    h = i.originalEvent.propertyName.toLowerCase() == "value"
  }
  if (h) {
    if (d(this).data("timeout")) {
      clearTimeout(d(this).data("timeout"))
    }
    d(this).data("timeout", setTimeout(function() {
      f._applySearchTermFilter()
    }, f.config.searchTimeout))
  }
}

I tried (yes, the text field has neither name nor id, just a placeholder attribute...)

$('input[placeholder="Click here to select project(s)"]')
   .focus()
   .val('MY-SEARCH-TEXT')
   .trigger("propertychange")

but that fails because the handler tries to access event.originalEvent, which jQuery doesn't set. Can I somehow fake an event which has this property?

Maybe it would alternatively be possible to go without an event and call _applySearchTermFilter() directly, but I also don't know how to do that, since all these functions are inside an anonymous IIFE (and f=this). Is such a function exposed through window in any way?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Found it, it's actually quite simple when one knows jQuery better:

$('input[placeholder="Click here to select project(s)"]')
    .focus()
    .val('MY-SEARCH-TEXT')
    .trigger($.Event('propertychange', {originalEvent: {propertyName: "value"}}));
about 4 years ago · Juan Pablo Isaza Relatório
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