Permalink
Browse files

fixed grouping logic

  • Loading branch information...
1 parent adcde13 commit 44d8d179c279dff16e010f1723ce0a723229334c @givp committed Aug 11, 2010
Showing with 16 additions and 3 deletions.
  1. +1 −0 data.js
  2. +15 −3 mainList.js
View
@@ -12,5 +12,6 @@ var myData = [
{"title":"Bear", "description":"Bears are awesome and they like honey"},
{"title":"Dog", "description":"Dogs are the best and they woof"},
{"title":"Deer", "description":"D'oh! a deer..."},
+ {"title":"Donkey", "description":"sdfsdfsdf"},
{"title":"Zebra", "description":"Zebras are stripey and cool"}
];
View
@@ -18,12 +18,24 @@ for (var i = 0; i < myData.length; i++)
{
// get first letter of each item for grouping
firstLetter = myData[i].title.substr(0,1);
- if(firstLetter != oldFirstLetter){
+
+ if(i == 0){
oldFirstLetter = firstLetter;
+ Ti.API.info(oldFirstLetter);
} else {
- oldFirstLetter = null;
- }
+
+ if(firstLetter == oldFirstLetter){
+ oldFirstLetter = null;
+ } else {
+ oldFirstLetter = firstLetter;
+ }
+
+ }
+
+
data.push({title:myData[i].title,hasChild:true,header:oldFirstLetter});
+
+ oldFirstLetter = firstLetter;
}
// add search bar

0 comments on commit 44d8d17

Please sign in to comment.