I have a number different functions on different pages that are bound $(document).ready(). I am writing an Ajax login script and want to be able to refresh the page state to reflect the changed login status without reloading the whole page. I'm hoping there's a nice simple way of doing this so I don't restructure all my other scripts.
Any ideas?
You can do something like this:
$(document).on('ready readyAgain', function() {
// do stuff
});
// At some other point in time, just trigger readyAgain
$(document).trigger('readyAgain');
$(document).on('ready') has been deprecated in jQuery 1.8 according to documentation. An alternative method is as follows:
function myReadyFunction(){}
$(myReadyFunction);
// at some other point, just call your function whenever needed:
myReadyFunction($);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With