Reputation: 22490
Is it possible (if yes how) to check, detect, listen or watch if
$('body').data('myValue',false)
changes to true?
Of course I change it somewhere to true. The clue is I change it when an animation finishes and need to check somewhere else if it is finished. So when it changed the value I have to do something..
Upvotes: 1
Views: 695
Reputation: 1540
There a few ways to do this:
Upvotes: 0
Reputation: 1075189
Of course I change it somewhere to true. The clue is I change it when an animation finishes and need to check somewhere else if it is finished.
This is where custom events can be handy. In the place where you change it:
$('body').data('myValue', true).trigger('datachanged');
and where you need to know:
$('body').on('datachanged', function() {
// Use the updated information
});
For more about custom events, search for "custom" on the on
API doc page and the trigger
API doc page.
Upvotes: 6