Manually executing an event in JavaScript

I have a class:

function x() { this.initialize = function () { } this.filterSelection = function (event, ui) { /* code */ } } 

I intercept the filterSelection method for other elements through:

 $(item).on("click", this, this.filterSelection ); 

When filterSelection is called, event.data strong> points to an instance of my class.

Now I need to call filterSelection manually from the initialize () method.

How can I do this to set the correct parameters?

+6
source share
1 answer

Adeneo answered this in jsfiddle, but only as a comment leaving this question open.

 this.filterSelection({data : this}, null); 
0
source

Source: https://habr.com/ru/post/955149/


All Articles