+1 for encapsulation. That was my first thought, but I wanted the ability to add the create_gets_sets method eventually, and since it is indiscriminate, hiding the values isn't cool :) we can take it a step further and write some things to hide the values, but I think the code i've posted is confusing enough for most people... maybe if there's call for it...
–
Luke SchaferNov 19 '09 at 0:36

I don't quite understand. How can you attach a variable to a hidden <input/> element?
–
Peter LeeDec 5 '12 at 23:44

1

I think Chuck is suggesting that you can set the value of the input using jquery and then and a .change() event listener. If you update the input's value with .val() then the .change() event callback will fire.
–
jarederajMar 24 '14 at 21:20

<input type="hidden" value="" id="thisOne" /> and with jQuery $("#thisOne").change(function() { do stuff here }); and $("#thisOne").val(myVariableWhichIsNew); and then the .change() will fire.
–
khaverimJun 28 '14 at 13:28

The keypress + mousedown events will also work if you're using an input field
–
JVE999Oct 24 '14 at 0:53

Was just thinking this could work and was about to add an answer like this, glad to see someone else has already tested it.
–
sage881 hour ago

A small jQuery extension that handles queuing callbacks to the
existence of a variable, object, or key. You can assign any number of
callbacks to any number of data points that might be affected by
processes running in the background. jQueue listens and waits for
these data you specify to come into existence and then fires off the
correct callback with its arguments.

I know this is an old question, but if you are doing this for debugging proposes, you can add a listener using your debugging tool at your browser same way you debug script.

Personally I'm using Firebug in Firefox, once opened, go to DOM tab, search for your variable, then (similarly to adding a breakpoints to script) add a breakpoints. It will break and scroll to the specific line of code that's going to process the change on the variable.