Answer the question
In order to leave comments, you need to log in
jQuery 1.9.0+ removed one feature, how to replace it?
Good day to all.
In our project, version 1.8.3 was used for a long time (yes, it's old, but it worked fine).
We decided to update the technology stack (versions), and now our hands have reached jQuery. Updated to the latest version and found that some of the functionality of the site no longer works.
Namely, $.event.trigger stopped working.
We used it for asynchronous "JS" responses from the server.
What is convenient? And it is convenient that on the page itself it was possible to subscribe the necessary elements so that they listen to some event, and by calling $.event.trigger the event was delivered to all subscribers. At the same time, the one who sends the message does not even have a clue whether someone is subscribed to his events and how to call them.
That is, there was a good division and it was very easy and pleasant to work that way. But here, in version 1.9.0, this all stops working abruptly. What can be replaced?
I really would not want to connect any pub / sub library.
They also say that you can include jquery-migrate, but, as I understand it, it will not help here, because it is designed to help the developer switch to new standards and features, and then disable this library.
Fiddle: jsfiddle.net/JsUWv/3552 (just change the version to an older version like 1.9.1)
Thanks everyone!
Answer the question
In order to leave comments, you need to log in
You can use the Global custom events
plugin . Here is your example
The logic is as follows
IMHO it's better to use a service layer to register handlers. I can't yet choose between a mediator and an observer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question