Skip to main content
added 1 character in body
Source Link
Ewan
  • 84.6k
  • 5
  • 91
  • 189

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, it has been suggested that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

Although here you can see that because we have to cratecreate the binding declaratively in the markup you don't have a reference to the button. to use in the scope of the lambda

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, it has been suggested that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

Although here you can see that because we have to crate the binding declaratively in the markup you don't have a reference to the button. to use in the scope of the lambda

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, it has been suggested that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

Although here you can see that because we have to create the binding declaratively in the markup you don't have a reference to the button. to use in the scope of the lambda

added 108 characters in body
Source Link
Ewan
  • 84.6k
  • 5
  • 91
  • 189

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, @Basilevs points outit has been suggested that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

.. Although here you can see that because we have to crate the binding declaratively in the markup you don't have a reference to the button.Although I'm looking at to use in the javascript and frowning as I typescope of the lambda

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, @Basilevs points out that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

...Although I'm looking at the javascript and frowning as I type

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, it has been suggested that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

Although here you can see that because we have to crate the binding declaratively in the markup you don't have a reference to the button. to use in the scope of the lambda

added 292 characters in body
Source Link
Ewan
  • 84.6k
  • 5
  • 91
  • 189

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raisevent">onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, @Basilevs points out that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

...Although I'm looking at the javascript and frowning as I type

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raisevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.

I've seen it said that this is so events can be bubbled up through several handlers while retaining information from the original raiser.

ie

<page> <control> <button onclick="raiseevent"> </control> </page> function raiseevent(e) { console.log(e.target.name) } //output: //button 

However, @Basilevs points out that your solution 2, with context capture can always be used to wrap a function that requires a reference to the target. ie.

<button onclick="(e) => { e.target= this; raiseevent(e); }"> 

...Although I'm looking at the javascript and frowning as I type

added 27 characters in body
Source Link
Ewan
  • 84.6k
  • 5
  • 91
  • 189
Loading
Source Link
Ewan
  • 84.6k
  • 5
  • 91
  • 189
Loading