Solved

How do I create an event handler for jQuery Migrate warnings?

Posted on 2014-10-28
2
237 Views
Last Modified: 2014-10-29
Hi jQuery experts!

I'd like to wire up error logging for when jQuery Migrate warnings come up. Is it possible to handle this event? If so, can you provide a basic example of how to create this event handler?

Thanks!
0
Comment
Question by:Drevo
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
check here : https://github.com/jquery/jquery-migrate/blob/master/src/migrate.js
see line 32:
console.warn( "JQMIGRATE: " + msg );

Open in new window

just add the following line after/before :
$(document).trigger("migrateWarn", [msg]);

Open in new window


and in your code, to be notified :
$(document).on("migrateWarn", function( event, arg1) { // http://api.jquery.com/on/ since jQuery 1.7
     alert("got it : " + arg1);
});

Open in new window


more infos :
http://learn.jquery.com/events/introduction-to-custom-events/
0
 

Author Closing Comment

by:Drevo
Comment Utility
Thank you so much for your very clear example as to how to accomplish this! It works great!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now