Hi,
function querer() {
var module ;
var action ;this.run = function ()
{
this.action = action ;
this.module = module ;
Dir ist klar das this.action und this.module nicht die oben mit var definierten Variablen sind?
~~~javascript
> function windowManager ()
> {
> this.windows = new Array() ;
>
> this.openWindow = function (bindto) {
> alert ( this.windows["name"] ) ;
> if ( typeof this.windows["name"] != "object" ) {
> this.windows["name"] = jQuery(bindto).window({
> x:50,
> y:50,
> title: "name",
> checkBoundary: true
> });
> }
> alert ( this.windows["name"] ) ;
> }
> }
this.windows ist so bei jeder Instanz die du mit new windowManager anlegst eine extra Variable.
Du möchtest nun über alle Instanzen von windowManager _ein_ Array windows haben, richtig?
Das würde ich wie folgt umsetzen:
var windowManager = (function(){ // Eine anonyme Funktion, eigentlich nur um ein extra Variablen-Scope zu erhalten in dem "windows" ist.
var windows = [], // new Array() ist unnötig
object = function(){} // Das eigentliche Objekt. Hat keine Konstruktor-Logik, daher leerer Function-Body
;
object.prototype.openWindow = function(bindto){ // Methoden des Objekts nicht über this.[MethodenName] im Function-Body erzeugen, da diese so für jede Instanz einzeln abgelegt werden. Über .prototype angelegte sind nur einmal vorhanden.
[…]
}
return object; // Das objekt zurückgeben. somit wird windowManager dieses Objekt zugewiesen
})()
~~~ // direkter Aufruf der anonymen Funktion