/var/log

Tag: Titanium

Titanium and localize moment.js

Titanium comes with a standard Moment.js library included. If you want to localize it, you have to require the locale you need. This needs to be done statically! So if you need a Dutch moment.js localization, you explicitly need to require it: require("/alloy/moment/lang/nl"); You cannot require it dynamically, because the compiler needs to include it […]

Install Titanium continuous builds

You can download and install continuous Titanium builds at: http://builds.appcelerator.com/ And then install it with something like: appc ti sdk install --branch 6_3_X 6.3.1.v20171101154403 These builds are not supported, so I only do this when the official versions have a bug that needs to be resolved asap.

Change Android homeAsUpIndicator icon in Titanium

For a project I wanted to show a hamburger menu icon in the main screen that shows a navigation drawer. The steps I did: I manually enabled the displayHomeAsUp property of the ActionBar and handled the onHomeIconItemSelected event to show the navigation drawer: $.mainWindow.activity.actionBar.displayHomeAsUp = true; $.mainWindow.activity.actionBar.onHomeIconItemSelected = function() { onMenu(); }; And also replaced the "back" […]

CLI import new project Titanium Appcelerator

If get the error "Application not registered" after trying to build a Titanium Project, you can use the following command to register the app from the CLI: appc new --import

Titanium webview and local content

Working with local HTML, Javascript and CSS files in a webview can be very tricky in Titanium Appcelerator for a few reasons: The path to the HTML file is different on iOS and Android. Javascript files are optimized and encrypted during compiling stage. Only Javascript files that are referenced from within HTML files are left […]

Titanium switch in listview item

I was using a listview with rows that had a label and a switch element. The switch element could be turned on or off and new items could be inserted into the listview. When new items where inserted I just replaced all items. This was giving me some nice surprise, as the value of the switch […]

Titanium fireevent and bubbling

In iOS events bubble up from child to parent view by default, but in Android you have to explicitly say so. For example if we have a parentview that adds a childview that has a button in it. After clicking the button, the childview fires a "logout" event on the button. The parent view listens […]

Titanium, Backbone and Promises

An easy way to let Backbone work with Promises in Titanium: Get the bluebird Promise library. Now you can add a fetchAsPromise to the Backbone.Model.Prototype and Backbone.Collection.prototype objects: Backbone.Model.prototype.fetchAsPromise = function(options) { var me = this; return new Promise(function(resolve, reject) { options.success = resolve; options.error = reject; me.fetch(options); }); }; The same can be done […]

TiShadow

TiShadow enables you to test faster on multiple devices at once. This is a step by step article to use it. If you want to use it on Android Genymotion emulators, you first have to install Google Apps on these emulators. TiShadow consists of 3 elements: The server that pushes apps and updates to the […]