titaniumappceleratorappcelerator-titaniumtitanium-alloyappcelerator-alloy

Use Underscore.js in a Titanium Alloy project


How do I use the built in underscore library in a Titanium Alloy project.

In the docs it says to do the following:

var _ = require("alloy/underscore")._;

However, whenever I do this, I get the following error:

17:22:55 [ERROR] [iphone, 10.3.3, 192.168.0.64] {
"message": "undefined is not an object (evaluating '_.extend')", 
"line": 1179, 
"column": 6, 
"stack": "Controller
createController
onClickDetails
"}

So my question is, how can I use the built in Underscore.js library in Alloy


Solution

  • It turns out underscore is already imported, so you can just use it without actually doing a require statement. e.g.

    Ti.API.info(_.VERSION);