Dovrei fare qualcosa del tipo
nel file primo.js
codice:function startSystemMenu(){ // Crea un'instanza della classe SystemMenu new Ajax.Request(SYSTEM_MENU_PAGE, { method: 'get', asynchronous: false, contentType: 'text/xml', onSuccess: function(transport){ systemMenu = new SystemMenu( transport.responseXML, NUM_LATERAL_BUTTONS, NUM_COULOUMNS); }, onFailure: function(){ alert("Status: " + ajax.status); alert("Errore: " + ajax.statusText); } }); ........ // Fa un 'update' del menu presentando il primo livello systemMenu.update('1', 1); ........
nel file SystemMenu.js
Ovviamente la cosa non funziona, altrimenti non sarei qui, l'errore che ottengo è SystemMenu.stampaId is not a function. Prima di scrivere SystemMenu.stampaId(param) avevo provato con this.stampaId(param) ma ovviamente al momento del click il this è rappresentato dall'immagine su cui si è cliccato.codice:var SystemMenu = Class.create({ initialize: function(xmlRef, numLateralButtons, coloumns){ ....... }, update: function(parentIdNode, page){ ....... this.riferimentoAdUnElementoIMG.onclick = function(){ SystemMenu.stampaId(param); }; }, stampaId: function(clickedNode){ alert(clickedNode.getAttribute('id')); }, });
Come ne esco? Grazie.
Lorenzo


Rispondi quotando