@titanium/turbo
Version:
<p align="center"> <img src="https://cdn.secure-api.org/images/turbo-title_400.png" /><br> <a href="https://www.npmjs.com/package/@titanium/turbo"> <img src="https://img.shields.io/npm/v/@titanium/turbo.png" /> </a> </p>
31 lines (25 loc) • 777 B
JavaScript
var locations = Alloy.Collections.locations;
function transformData(model) {
var attrs = model.toJSON();
attrs.imageUrl = '/' + attrs.direction + '.png';
attrs.upperCaseName = attrs.name.toUpperCase();
return attrs;
}
function doChanges(e) {
// grab a random model by index
var index = Math.round((locations.length - 1) * Math.random());
var model = locations.at(index);
// modify the model...
model.set(
// just add a + to the end of the model's name
{ name: model.get('name') + '+' },
// set silent to true to prevent data binding
// from firing automatically. Silent changes will
// not trigger data binding to update.
{ silent: true }
);
}
// call the binding function name we defined in the
// dataFunction attribute
updateUi();
$.index.open();