Skip to content

Instantly share code, notes, and snippets.

@andreaj8
Created January 20, 2014 14:24
Show Gist options
  • Save andreaj8/8520722 to your computer and use it in GitHub Desktop.
Save andreaj8/8520722 to your computer and use it in GitHub Desktop.
Titanium Alloy ( 3.2.0) Table View strange behavior
(function() {
$.save.enabled = false;
var u = user.getCurrent();
$.textFName.value = u.custom_fields ? u.first_name + " " + u.last_name : "";
$.textFphone.value = u.custom_fields ? u.custom_fields.number : "";
$.textFmail.value = u ? u.email : "";
$.profilePic.image = u.photo.urls ? u.photo.urls.small_240 : "sample-img.png";
Alloy.Globals.interestStatus = u.custom_fields ? u.custom_fields.interest : [];
var data = $.table.getData();
data.push(Ti.UI.createTableViewSection({
headerTitle : 'Interessi'
}));
for (var i in Alloy.Globals.interests) {
data.push(Alloy.createController('interest', {
title : Alloy.Globals.interests[i].title,
saveButtonREF : $.save
}).getView());
$.table.setData(data); // <---- this is the reason of strange behavior
}
// $.table.setData(data); //<--- this is correct
})();
<!--IOS-->
<NavigationWindow id="profile" platform="ios">
<Window>
<LeftNavButton>
<Button title="Left" onClick="openLeft"></Button>
</LeftNavButton>
<RightNavButton>
<Button id="save" title="salva" onClick="save" visible="false"></Button>
</RightNavButton>
<TableView id="table" class="table">
<TableViewSection id="sectionFish" headerTitle="Info">
<TableViewRow class="profilePicRow">
<ImageView id="profilePic" class="img-circle-sm" image="sample-img.png" onClick="camera" />
<Label id="message" text=" I tuoi dati saranno importanti per essere contattato dagli utenti"></Label>
</TableViewRow>
<TableViewRow>
<TextField
id='textFName'
class="text"
platform='ios'
hintText="your name">
<!-- Sets the keyboardToolbar property -->
<KeyboardToolbar>
<Toolbar>
<Items>
<Button systemButton="Ti.UI.iPhone.SystemButton.CANCEL" onClick="canceln"/>
</Items>
</Toolbar>
</KeyboardToolbar>
</TextField>
</TableViewRow>
<TableViewRow>
<TextField
class="text"
id='textFphone'
platform='ios'
hintText="phone number"
>
<!-- Sets the keyboardToolbar property -->
<KeyboardToolbar>
<Toolbar>
<Items>
<Button systemButton="Ti.UI.iPhone.SystemButton.CANCEL" onClick="cancelp"/>
</Items>
</Toolbar>
</KeyboardToolbar>
</TextField>
</TableViewRow>
<TableViewRow>
<TextField
id="textFmail"
class="text"
platform='ios'
hintText="my@mail.com"
>
<!-- Sets the keyboardToolbar property -->
<KeyboardToolbar>
<Toolbar>
<Items>
<Button systemButton="Ti.UI.iPhone.SystemButton.CANCEL" onClick="cancelm"/>
</Items>
</Toolbar>
</KeyboardToolbar>
</TextField>
</TableViewRow>
</TableViewSection>
</TableView>
</Window>
</NavigationWindow>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment