Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
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)

726 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