Quantcast
Viewing all articles
Browse latest Browse all 26

Template Support in Alloy

Hi all-

I was curious if Alloy supported templates. Let me give you an example of what I am looking to do. In the same way that I can setup a TableView with TableViewRows, and bind a collection to the TableView, which then iterates over the collection and uses the TableViewRow as a "template" for the collection of data, is there a way if I am not using binding, but have an array of data that I would like to throw into a Table and iterate over a template of TableViewRows to have a template defined?

Here is my scenario. I save a model as such:

if (order.isValid()) {
 
  order.save(null,
    success: function(a,b,c) {
      cleanUpOrderDlg();
    },
    error: function(model, xhr, options) {
 
      Ti.App.fireEvent('orderError', {
        id:  orderId,
        name:  orderName,
        /* order Properties sent here to rebuild model */
      }
 
    }
 
  });
 
}
The save request actually returns an error code of 400 to trigger the user to accept possibly some additional criteria, which is sent in the reponse object as a json data object. That json data object is the object I would love to use as my new "collection" to place within a template and iterate over, as such, where, as in the binding, I could define a template that could pull a field and iterate over the collection:
<Alloy>
  <View>
    <TableView>
      <TableViewRow>
        <Label text={FieldFromJsonCollection} />
      </TableViewRow>
    </TableView>
  </View>
</Alloy>
Is defining a template in Alloy like the above to take a response collection possible?

Thanks so much for any help. Chris


Viewing all articles
Browse latest Browse all 26

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>