javascript - Appcelerator / Titanium Alloy - how to manipulate a string before it gets added to the view -
i have titanium alloy view, outputs tableview
image thumbnail each one. achieved passing url image
attribute of imageview
element. alloy view populated alloy collection, handles looping of data me:
<tableview id="brandslist" datacollection="brands"> <tableviewrow brandid="{brand_id}"> <view class="vgroup"> <imageview height="45" width="80" id="image" image="{image}" /> <label id="name" text="{name}" /> </view> </tableviewrow> </tableview>
however, i'd change url string bit before gets view above. specially need add values in middle of url change image quality , size. how can catch string string value , make changes?
from looks of code appears doing data-binding. can transform data before presented in view
http://docs.appcelerator.com/titanium/latest/#!/guide/alloy_data_binding
<tableview id="brandslist" datacollection="brands" datatransform="transformfunction"> <tableviewrow brandid="{brand_id}"> <view class="vgroup"> <imageview height="45" width="80" id="image" image="{image}" /> <label id="name" text="{name}" /> </view> </tableviewrow> </tableview>
then in code
function transformfunction(model) { // need convert model json object var transform = model.tojson(); transform.image = /* someting image url string */; return transform; }
Comments
Post a Comment