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

558 views Asked by At

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?

1

There are 1 answers

0
rjcpereira On BEST ANSWER

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