2008/11/24 bricklemacho <[EMAIL PROTECTED]>:
> ----
> config.macros.myMacro = {
>  handler: function(place, macroName) {/* ... */},
>  School: function(){/*...*/},
>   //  School.prototype.method1: function(){/*..*/}  // ERROR!
> };
> config.macros.myMacro.School.prototype.method2=function(){/*..*/};  //
> OK!
> ----
This is in fact a syntax error. The curly bracketed syntax for
defining an object/hash list has the limitation that you can only put
member names before the each colon, not object references.
Putting
School.prototype.method1: function(){/*..*/}
in a curly bracket object definition is just as wrong as putting
window.onload: function(){/*..*/}

However you can use a function that takes the constructor and
prototype as arguments, constructs the function with the prototype and
returns it.

function createPrototypedFunction(c, p){
        c.prototype = p;
        return c;
}

config.macros.myMacro = {
        handler: function(place, macroName) {/* ... */},
        School: createPrototypedFunction(
                function(){
                                /* This will become the constructor */
                },
                {
                        method1: function(){/*..*/},
                        method2: function(){/*..*/},
                }
        )
}

I've expanded the code more than needed to make it readable.

/Ove

-----BEGIN 2ROT13 MESSAGE-----
Low Bitrate Netlabel: <http://flb.gg8.se/>
Blog:
<http://gameboygenius.8bitcollective.com/>
SKRIVA på Lysator. Ditt Ahrvid-fria alternativ:
<http://lists.lysator.liu.se/mailman/listinfo/korkek?SKRIVA?>
Sätt på ett par flipflops, vippa på rumpan
och gör det här till en minnesvärd sommar!
-----END 2ROT13 MESSAGE-----

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to TiddlyWikiDev@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/TiddlyWikiDev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to