replaceincludetitaniumappceleratorliveview

Appcelerator Titanium: Ti.include causes error "Object false has no method 'replace'" in Liveview


I found that when launching an Alloy project in Appcelerator Titanium with Liveview enabled i got the error "Object false has no method 'replace'" caused by this line in the controller:

Ti.include("/common/Globals.js");

I don't see any error if i launch the same project with Liveview disabled. Does anyone know what could be the problem?


Solution

  • Ti.include is deprecated, and will never work in LiveView mode.

    You should use require instead:

    var yourName = require('your_file');
    

    your_file.js

    exports.myProperty = 'hi';
    

    yourName.myProperty will return 'hi'

    http://docs.appcelerator.com/platform/latest/#!/guide/CommonJS_Modules_in_Titanium