Salve ragazzi, il problema che riscontro, è che quando creo una serie di elementi con una funzione, e poi con un altra faccio una selezione su tali elementi, il risultato è che come se non esistessero gli elementi creati nella prima funzione.
Uso Mootools...
Codice PHP:
var Gallery = new Class({
initialize: function(listaXML){
this.xml = listaXML;
},
creaGallery: function(){
var req = new Request({
url:this.xml,
update: $("content_gallery"),
onRequest: function(){
},
onSuccess: function(txt, xml){
doc = xml.documentElement;
imgs = doc.getElementsByTagName("img");
imgs_length = imgs.length;
for(i=0; i<imgs_length; i++){
id = imgs[i].attributes.getNamedItem("id").value;
src= imgs[i].attributes.getNamedItem("src").value;
nome_img = imgs[i].attributes.getNamedItem("name").value;
w = imgs[i].attributes.getNamedItem("w").value;
h = imgs[i].attributes.getNamedItem("h").value;
el = new Element("img",{
"id":id,
"styles":{ "width":w+"px", "height":h+"px", "background-color":"black",
"float":"left", "margin":"10px", "border":"2px solid black"
},
"src":src+"/Thumbs/"+nome_img
}).inject($("content_gallery") );//END ELEMENT
}//FOR
//alert($$("img").length);
}//END onSuccess
}).send(null);//END REQUEST
},//END creaGAllery
funzioneGenerica: function(){
alert($$("img").length);//CHE DA COME RISULTATO "ZERO"
}
});//END CLASS GALLERY
Spero abbiate capito cosa intendo, grazie.