cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Click Event on Video Widget

SOLVED
mn1
Aquamarine

Click Event on Video Widget

Hey there,

Is there a possiblity to catch the click event on a video widget? If I catch all click events how can i get the ID of the widget which is clicked?

Thanks for help.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Click Event on Video Widget

I solved the problem alreay by myself!

View solution in original post

6 REPLIES 6

Re: Click Event on Video Widget

I solved the problem alreay by myself!

View solution in original post

Re: Click Event on Video Widget

What was your solution?

Highlighted

Re: Click Event on Video Widget

Hi,

I added an Event Handler:

window.addEventListener('click', $scope.Ausgabe);

and in the function Ausgabe I checked, if the click Event was sendet by a Video:

 

$scope.Ausgabe=function(){
console.log("A click event is recived");
if (window.event.path[0].tagName=='BUTTON'|| window.event.path[0].tagName=='IMG'){
console.log(window.event.path[2].attributes["0"].nodeValue); // if an image or button was clicked, this line prints the id
}
if (window.event.path[0].tagName=='VIDEO'){
console.log(window.event.path[3].attributes["0"].nodeValue); // If a video was clicked, this line prints the id

}

Re: Click Event on Video Widget

Excellent, thanks for the explanation.

Re: Click Event on Video Widget

Hi @ClayHelberg ,

 

here I want  to clarify it furhter based on my experience.

So in the @mn1 's example the solution is based on particular windget configuration and will not work and every project - so need adoption in particular situation . So I did an example and it the code was not working in this case. So to get it working I needed to go in chrome in the  console debugging  Strg -Shift -I and  do some thing like:

//////////////////////////////////////////////////////
document.addEventListener('click', function(event) {
console.log("click() 1 called");
                                          
 console.warn(event);                                                   
});

And then to check the console warning in the console window and to try to explore the current setting of the event object:

 

2019-02-21_16-53-20.gif

 

In my case for the video widget  the correct expression should be:

 

...
if (window.event.path[0].tagName=='VIDEO'){
console.log(window.event.path[0].attributes["0"].nodeValue);
 // If a video was clicked, this line prints the video source
console.log(window.event.path[3].attributes["0"].nodeValue);
// If a video was clicked, this line prints the video source
}
...

 

2019-02-21_16-53-50.gif

2019-02-21_17-06-37.gif

Re: Click Event on Video Widget

Thanks for the elaboration, @RolandRaytchev . That will be helpful info to file away for future reference.