Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda