Is it possible to have an event in JS that fires when the value of a certain variable changes? JQuery is accepted.
AngularJS (I know this is not JQuery, but that might help. [Pure JS is good in theory only]):
AngularJS
JQuery
$scope.$watch('data', function(newValue) { ..
where "data" is name of your variable in the scope.
There is a link to doc.