load() method deprecated?
I was browsing through the jQuery api and noticed that the load method is on the deprecated list.
Categories: Deprecated | Events > Document Loading
I usually use this method to check if images are completly loaded. Why is it deprecated? And what am I supposed to be using instead?
See bug #11733, which documents this deprecation:
The
.load()
method is an ambiguous signature, it can either be an ajax load or attach/fire a "load" event. CCAO cannot tell them apart since it's a dynamic decision based on arguments.
To avoid ambiguities related to the method's signature, it is now recommended to use on() instead. For instance:
$("selector").load(function() {
// ...
});
Should become:
$("selector").on("load", function() {
// ...
});