[POO] Accès à une instance objet depuis un enfant
Bonjour à tous !
Voila j'ai un petit problème avec le javascript Objet.
En gros, je créé une boite avec un titre. dans le titre j'ai des boutons. Depuis leurs méthodes onmousedown, j'aimerai accéder à la box pour lancer sé fonction Edit().
Comment est-ce possible ?
Voici le code en question :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
function Bar(title){
this.Content=document.createElement("div");
this.Content.setAttribute("class","bar");
this.Content.appendChild(document.createTextNode(title));
this.fermer=document.createElement("img");
this.fermer.setAttribute("src","images/icons/close.gif");
this.fermer.setAttribute("class","button");
this.edit=document.createElement("img");
this.edit.setAttribute("src","images/icons/edit.gif");
this.edit.setAttribute("class","button");
this.edit.onmousedown=function(){
?????????
}
this.Content.appendChild(this.edit);
this.Content.appendChild(this.fermer);
}
function BoxMembersManager(title){
this.Box=Box();
this.Bar=new Bar(title);
this.Infos=new Infos();
ObjectDraggable(this.Bar);
this.Box.appendChild(this.Bar.Content);
this.Construct=function(){
var containertext=document.createElement("div");
..................
this.Infos.appendChild(containertext);
this.Box.appendChild(this.Infos);
}
this.Edit=function(){
}
} |
Merci beaucoup d'avance pour votre réponse !
Accès à une instance objet depuis un enfant Répondre à la discussion [RESOLU]
Yes !
Ca marche du tonnerre !
Par contre, je ne comprend pas bien ce que c'est que ce "(this)" tout seul.
Est-ce que t'aurais une petite explic ?
En tout cas, ça c'est RESOLU !
Merci beaucoup à vous 2