Revision: 11763
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 17, 2009 14:35 by johnloy
Initial Code
/* A similar pattern to the module pattern is the “shared singleton†— create a singleton object for an application that can be used to share properties or methods between pages or inline frames. Here’s the start of a “my.js†script that every page or frame in an application could share: */ if (typeof parent.my != “undefinedâ€) { var my = parent.my; // shared singleton } else { var my = {}; my.something … } /* The “parent†bit is so that the script can be used with iframes and still retain a reference to the same “my†instance. If a page is at the top, then parent points to itself. Every page or frame that imports “my.js†can share properties or methods with any other page. */
Initial URL
Initial Description
Initial Title
Shared singleton pattern for sharing utility methods across pages
Initial Tags
textmate
Initial Language
Other