Create a gist now

Instantly share code, notes, and snippets.

DynamicLabel tag in Alloy - allows you to update a "value" and it applies it to a template. Place ui.js in your app/lib folder
$.recordCount.value = 99
<Alloy>
<View class="container">
<DynamicLabel module="ui" id="recordCount" value="0" template="? Records"/>
</View>
</Alloy>
exports.createDynamicLabel = function(args) {
var label = Ti.UI.createLabel(args);
function updateText() {
label.text = label.template.replace("?", label.value);
}
label.getValue = function() {
return label.value;
};
label.setValue = function(value) {
label.value = value;
updateText();
};
updateText();
return label;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment