/* listen for the submit button press */
YAHOO.util.Event.addListener(webserver.result_form, 'submit', webserver.result_submit);
I have this event listener in my main.js. Is there any way in YUI so I can listen a variable, so when this variable changes the event occurs. I was wondering if there is something like :
YAHOO.util."Variable".addListener(webserver.result_form, 'submit', webserver.result_submit);
you can not directly assign listener to javascript variable but you can do it indirectly in following manner.
you can save the value of a variable in a div or any html node
e.g.
or
and then use following js to monitor any change in the node.
This will work in YUI3 or above. ( I am not sure about YUI2.x)
for more info about listening for events to YUI node
http://yuilibrary.com/yui/docs/event/#listening-for-events
and lists of events available
http://yuilibrary.com/yui/docs/event/#event-whitelist
EDIT
based on http://www.quirksmode.org/dom/events/change.html,
change event only fires if its form field
e.g.
inputtextareaandselectso change event will not fire when contents of div is changed.