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

144
Views
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 answers
Answer question

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 Report
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!