<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>
-
URL
<The URL Structure (path only, no root url)>
-
Method:
/* Kosso : March 12th 2011 | |
This the only way I managed to do this without the app crashing on resume. | |
Done slightly differently to the KS example, since they unregister the service and | |
do not use a setInterval timer. | |
*/ | |
//############ in app.js : | |
// test for iOS 4+ |
/* The API controller | |
Exports 3 methods: | |
* post - Creates a new thread | |
* list - Returns a list of threads | |
* show - Displays a thread and its posts | |
*/ | |
var Thread = require('../models/thread.js'); | |
var Post = require('../models/post.js'); |
(function () { | |
if (typeof Ti !== 'undefined') return; | |
var global = new Function('return this;')(); | |
var Titanium = function () {}; | |
Titanium['API'] = function () {}; | |
Titanium['Accelerometer'] = function () {}; | |
Titanium['Analytics'] = function () {}; | |
Titanium['Android'] = function () {}; |
// I was unhappy about there was close to no control over the "pageControl" | |
// in scrollableViews, so I hacked my own | |
// ----- | |
// Configuration | |
var pageColor = "#c99ed5"; | |
PagingControl = function(scrollableView){ | |
var container = Titanium.UI.createView({ | |
height: 60 |
$.index.open(); | |
// create an instance of the model | |
var model = Alloy.createModel('myModel'); | |
// listen for the "error" event | |
model.on('error', function(model, error) { | |
Ti.API.info('error handled: ' + error); | |
}) |
If you want to your CommonJS modules to work in both Alloy and plain Titanium projects, you might need a way to detect if you're in Alloy. For instance, if you're in Alloy you would get Underscore from the alloy-module, while in plain Titanium you would require Underscore directly.
Well, you can:
var _ = require((typeof ENV_TEST === 'boolean') ? 'alloy' : 'underscore')._;
The above works by utilizing Alloy's optimization process. In this process, constants like ENV_TEST
will be either TRUE
or FALSE
. The actual expressions in wich they are used will then be evaluated. If FALSE
the code block will be removed. In plain Titanium projects the constants are undefined and this typeof ENV_TEST
will be undefined
, so the code block will be executed.
Often I need to display a user-provided picture in an ImageView in such a way that the whole ImageView is filled with as much of the picture possible.
This is how I do it:
var image = require('image');
Ti.Media.showCamera({
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
success: function (e) {
I guess just like me you like to do alert('My message');
instead of:
Ti.UI.createAlertDialog({
message: 'My message'
}).show();
But I'd even more like to do alert('My message', 'My title', myCallback);
instead of: