Skip to content

Commit 91a5a76

Browse files
author
Tim Statler
committed
Updated updateViews() sample, and addressed other issues.
1 parent 0d09b95 commit 91a5a76

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

Alloy/lib/alloy/controllers/BaseController.js

+30-25
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ var Controller = function() {
223223
* {@link Titanium.UI.View#method-applyProperties applyProperties} method
224224
* or a create object method, such as {@link Titanium.UI#method-createView Titanium.UI.createView}.
225225
* #### Examples
226-
* The following creates a new style object that passed as a parameter
226+
* The following creates a new style object that is passed as a parameter
227227
* to the {@link Titanium.UI#method-createLabel Ti.UI.createLabel()} method.
228228
229229
var styleArgs = {
@@ -238,7 +238,7 @@ var Controller = function() {
238238
testLabel = Ti.UI.createLabel(styleObject);
239239
240240
* The next example uses the {@link Titanium#method-applyProperties applyProperties()} method
241-
to add apply a style object to an existing Button control (button not shown).
241+
* to apply a style object to an existing Button control (button not shown).
242242
243243
var style = $.createStyle({
244244
classes: args.button,
@@ -351,34 +351,39 @@ The 'redbg' and 'bigger' classes are shown below:
351351
/**
352352
* @method updateViews
353353
* Applies a set of properties to view elements associated with this controller.
354-
* @param {Object} args An object whose keys are the IDs (in form '#id') of views to which the styles will be applied.
355-
* @since 1.4.0
354+
* This method is useful for setting properties on repeated elements such as
355+
* {@link Titanium.UI.TableViewRow TableViewRow} objects, rather than needing to have a controller
356+
* for those child controllers.
356357
* #### Example
357-
* The following example updates the UI elements with IDs "container"
358-
* and "name", providing new values for the `layout` and `text`
359-
* properties of those elements, respectively.
358+
* The following example uses this method to update a Label inside a TableViewRow object
359+
* before adding it to a TableView.
360+
361+
* View-controller file: controllers/index.js
362+
363+
for (var i=0; i < 10; i++) {
364+
var row = Alloy.createController("tablerow");
365+
row.updateViews({
366+
"#theLabel": {
367+
text: "I am row #" + i
368+
}
369+
});
370+
$.tableView.appendRow(row.getView());
371+
};
360372
361-
* View-controller file: controllers/profile.js
373+
* XML view: views/tablerow.xml
362374
363-
var profile = Alloy.createController('profile');
364-
profile.updateViews({
365-
"#container" : {
366-
layout : "vertical"
367-
},
368-
"#name" : {
369-
text : "Mr. Jones"
370-
}
371-
});
372-
$.index.add(profile.getView());
373-
$.index.open();
375+
<Alloy>
376+
<TableViewRow>
377+
<Label id="theLabel"></Label>
378+
</TableViewRow>
379+
</Alloy>
374380
375-
* XML view: views/profile.xml
381+
* XML view: views/index.xml
376382
377-
<Alloy>
378-
<View id="container">
379-
<Label id="name"/>
380-
</View>
381-
</Alloy>
383+
<TableView id="tableView">
384+
</TableView>
385+
* @param {Object} args An object whose keys are the IDs (in form '#id') of views to which the styles will be applied.
386+
* @since 1.4.0
382387
383388
*/
384389
updateViews: function(args) {

0 commit comments

Comments
 (0)