Last active
August 29, 2015 14:01
-
-
Save jasonkneen/d8b738ecc8379e3c01ba to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.recordCount.value = 99 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<View class="container"> | |
<DynamicLabel module="ui" id="recordCount" value="0" template="? Records"/> | |
</View> | |
</Alloy> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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