How to detect that both onOK and onChange are being thrown ?

asked 2015-10-22 17:54:12 +0800

WilliamB gravatar image WilliamB
1609 1 6

I've a combobox showing autocompletion.

I've added a listener for both onOK and onChange that throw the same event.

Is there a way for me detect when onChange and onOK are getting thrown at the same time so i don't get double event thrown?

Something like stopPropagation() that I could call.

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted

answered 2015-10-26 09:17:04 +0800

Darksu gravatar image Darksu
1991 1 4

Hello WilliamB,

  1. Create a boolean variable
  2. Once the event is triggered set the value to true and create a internal timer (thread independent) that would complete it's operation in an x amount of seconds so that you will prevent any other actions from being executed
  3. Once the timer is done set the variable again to false

Between us maybe you should not trigger both events, but if you apply the logic above it will work.

Best Regards,


link publish delete flag offensive edit

answered 2015-10-26 10:58:37 +0800

WilliamB gravatar image WilliamB
1609 1 6

Well It's weird, if I do not add a "onOK" listener, the "onChange" event listeners is not triggered when i press Enter.

If I add a "onOK" listener, the "onChange" event listeners triggered when i press Enter.

So I just went and added a listener onOk that does nothing just to trigger onChange ...

link publish delete flag offensive edit

answered 2016-01-07 17:55:19 +0800

WilliamB gravatar image WilliamB
1609 1 6

Alright, I'm back on that issue.

I want that if the user press ENTER it triggers an event. Since the field is an autocomplete one, enter can trigger onChange.

But mouse click can also trigger onChange

I want to trigger the event whenever onChange or onOk is thrown BESIDE when the onOk also will trigger an onChange.

Is there no cleaner way to do this than to add a timer?

link publish delete flag offensive edit


forward the onOk event to the onChange event?

chillworld ( 2016-01-07 19:20:41 +0800 )edit

Wouldnt that just retrigger onChange twice?

WilliamB ( 2016-02-09 13:58:17 +0800 )edit

I don't think so : http://zkfiddle.org/sample/2iraa2u/1-forwarding

chillworld ( 2016-02-09 14:22:23 +0800 )edit

Thanks Chill, I ll check.

WilliamB ( 2016-02-10 09:24:54 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2015-10-22 17:54:12 +0800

Seen: 50 times

Last updated: Jan 07 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More