[Dojo-interest] javascript : copy or reference

Thibaut thibaut at fuse.co.uk
Thu Feb 8 04:54:24 MST 2007


Hi

In the following example the "i" variable seems to be passed by  
reference to the getClientList(i)
Therefore getClientList(9) is always called !

			for(var i=1; i<=8; i++) {
				var span2 = document.createElement("span");
				dojo.byId('pagelist').appendChild(span2);
				dojo.event.connect(span2, 'onclick', function(e) {getClientList 
(i);});
			}


How can i manage to call getClientList(1), getClientList(2) ...  
getClientList(8) ?

Thibaut








More information about the Dojo-interest mailing list