Answer the question
In order to leave comments, you need to log in
How to create your own event in JS (you can use JQuery)?
It is required that it be possible to use the construction:
$(elem).on('customEvent', function(param1, param2, param3) { /*...*/ });
$(elem).on('pjax:success', function(data, status, xhr, options) { /* ... */ });
Answer the question
In order to leave comments, you need to log in
$(document).on('customEvent', function(event, param1, param2, param3) {
console.log(param1, param2, param3);
});
$(document).trigger("customEvent", [ "param1", "param2","param3" ]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question