mam kod pisany z użyciem mootools:
var Cache = new Class({ items: new Array(), add: function(id, obj) { this.items[id] = obj; }, get: function(id) { return this.items[id] ? this.items[id] : false; } }); var Cache_Data = Cache.extend(); var Cache_Template = Cache.extend(); var Loader = new Class({ initialize: function() { this.templates = new Cache_Template(); this.datas = new Cache_Data(); this.counter = 0; trace("Loader initialize"); }, load: function(data, template) { var ch = new Chain(); ch.chain(function(){ new XHR({ onSuccess: function(){ var content = this.response.text; content = content.replace(/id="([a-z0-9]*)"/g, "id=\"$1[" + this.counter + "]\""); // tutaj $("content").innerHTML = content; } }).send(template + ".php"); }).chain(function(){ new Json.Remote(data + ".php",{ onComplete: function(response){ for (var i in response) { $(i + "[" + this.counter + "]").innerHTML = response; // no i tutaj } } }).send(); }); var timer = (function() { (ch.chains.length == 0) ? $clear(timer) : ch.callChain(); }).periodical(1); this.counter++; } });
Nie mam koncepcji w jaki sposób odwołać się do składowej [i]counter z klasy Loader. Późniejszym problemem będzie również odwołanie się do składowej templates oraz datas - domyślam się, że najlepiej byłoby to zrobić za pomocą singletona ale wszelkie kody jakie znalazłem nt. singeltona w JS nie działają

Prosiłbym więc o naprowadzenie mnie na to jak zrobić aby składowe klasy Loader były widoczne oraz dostępne w wywołaniach XHR.
Dzięki za pomoc,
pion.