hallo again Stefan,
...
this.remove = function(panel) {
container[panel.id] = null;
// delete container[panel.id];
}
// };
>
> Ist das besser als = null?
nach der \*reinen lehre\* schon. der [null] wert regt in diesem fall
den garbage collector nicht dazu an, endgueltig aufzuraeumen, da
sich das private "container" objekt permanent im scope seines
[Container]-objekts befindet (solange letztgenanntes existiert).
> ...
> Und wie gelingt es mir, nur die Panels auszulesen?
versuch:
~~~javascript
var Container = function () {
var i, panels = [];
this.addPanel = function (panel) {
panels.push(panel);
};
this.removePanel = function (panel) {
for (i=0; i<panels.length; ++i) {
if (panels[i].id == panel.id) {
break;
}
}
panels = (panels.slice(0, i)).concat(panels.slice(i+1)); // ungetestet!
};
this.setPanel = function (id) {
for (i=0; i<panels.length; ++i) {
//alert(panels[i]);
if (panel.id == id) {
panel.display();
} else {
panel.hide();
}
}
};
};
var Panel = function (id) {
this.id = id;
this.display = function () {
$(this.id).style.display = "block";
//$(this.id).style.display = ""; // stellt den default wieder her;
};
this.hide = function () {
$(this.id).style.display = "none";
};
};
so long - peterS. - pseliger@gmx.net
--
»Because objects in JavaScript are so flexible, you will want to think differently about class hierarchies.
Deep hierarchies are inappropriate. Shallow hierarchies are efficient and expressive.« - Douglas Crockford
ie:( fl:) br:> va:( ls:& fo:) rl:| n3;} n4:} ss:} de:µ js:} mo:? zu:]
»Because objects in JavaScript are so flexible, you will want to think differently about class hierarchies.
Deep hierarchies are inappropriate. Shallow hierarchies are efficient and expressive.« - Douglas Crockford
ie:( fl:) br:> va:( ls:& fo:) rl:| n3;} n4:} ss:} de:µ js:} mo:? zu:]