Solved

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

Posted on 2014-10-28
2
262 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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…

737 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