Monday, August 22, 2005

AJAX needs an observer pattern

Certain things are useful, and AJAX controls most definately couldwill benefit from it.

The idea behind the observer pattern is something you're already familar with: onchange="foo()". However, things get messy when you have to observe the state of a hidden control updated by javascript.

Since I don't have access to the javascript that does the modifying of the hidden control, I need to be able to add an EventListener for modifications of the value via javascript.


//Wonderful psuedocode
var inputA = new Input();
var inputB = new Input();

inputB.value = &inputA.value;
inputA.value = foo;


Or



//Wonderful psuedocode
var inputA = new Input();
var inputB = new Input();

inputA.addEventListener('observerNotify',function() { inputB.value = inputA.value; }, false);

Since I don't have this at the moment, cross browser, it hampers invisibly updating controls and different parts of the UI...
Post a Comment