Questions tagged [event-binding]

Event binding connects an event handler to a specific event.

Event binding is the process of connecting (binding) an event-handler to an event listener.

The event handler is usually inline code or a function call, and is executed when an event happens to an object listening for the event.

In this code:

<button onclick="handleClick();">

onclick is the event listener and handleClick() is the event handler. The code binds handleClick to a click event on the button.

References

147 questions
170
votes
6 answers

Direct vs. Delegated - jQuery .on()

I am trying to understand this particular difference between the direct and delegated event handlers using the jQuery .on() method. Specifically, the last sentence in this paragraph: When a selector is provided, the event handler is referred to as…
moey
  • 10,587
  • 25
  • 68
  • 112
73
votes
8 answers

How to bind event listener for rendered elements in Angular 2?

How can I bind an event listener in rendered elements in Angular 2? I am using Dragula drag and drop library. It creates dynamic HTML but my event is not bound to dynamic HTML elements.
Sudhanshu sharma
  • 1,917
  • 3
  • 20
  • 29
27
votes
4 answers

Override all JavaScript events bound to an element with a single new event

Assuming that there are a large number of elements throughout the site that have an unknown number and type of events bound to them. If I need to override all of these events with one single bound event, and only that event will fire, what are some…
jerome
  • 4,809
  • 13
  • 53
  • 70
26
votes
6 answers

lostfocus/onblur event in knockout

I want to execute an event on a knockout observable bound to an input. This function should be executed when the control lose focus, even without typing anything. I tried to change the event binding but it doesn't fire when the user moves away from…
devC
  • 1,384
  • 5
  • 32
  • 56
10
votes
3 answers

TextBox.TextChanged & ICommandSource

I am following the M-V-VM pattern for my WPF UI. I would like to hook up a command to the TextChanged event of a TextBox to a command that is in my ViewModel class. The only way I can conceive of completing this task is to inherit from the TextBox…
Brad Leach
  • 16,857
  • 17
  • 72
  • 88
9
votes
6 answers

What is the best way to add an event in JavaScript?

I see 2 main ways to set events in JavaScript: Add an event directly inside the tag like this: do foo Set them by JavaScript like this: do bar and add an event in a