?
Solved

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

Posted on 2014-10-28
2
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 40410408
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
ID: 40411052
Thank you so much for your very clear example as to how to accomplish this! It works great!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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…
Suggested Courses

762 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