Using 'this' here is dangerous because you don't know what the caller is actually going to bind this function to. The typical workaround is to avoid using the this keyword unless you really want it's context-sensitive binding (DOM event handlers for example).  For module files, the usual way is to replace the "return" above with "var that = ", replace this -> that where necessary, and then add a "return that;" at the end of the module.  Most of the uses of this in this file should be replaced, except those in the click handlers, etc.