| GitHub Issue | n/a |
| Type | Bug |
| Priority | n/a |
| Status | Resolved |
| Resolution | Done |
| Resolution Date | 2018-05-14T15:19:54.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Titanium SDK & CLI |
| Labels | ListView, TextField, scroll |
| Reporter | Christoph Eck |
| Assignee | Shak Hossain |
| Created | 2018-05-14T09:16:34.000+0000 |
| Updated | 2018-05-14T15:20:00.000+0000 |
*Issue*
Lost value on scrolling down the ListView.
*actual behavior*
1. Compile and start on device
2. Enter a text like "Hello 123"
3. Scroll down and up again
4. You read "Hello"
*expected behavior*
1. Compile and start on device
2. Enter a text like "Hello 123"
3. Scroll down and up again
4. You read "Hello 123"
When working with text-fields or text-areas in list-views, you need to persist the value in the list via
updateItemAt, so the internal data structure gets updated as well. This is a common scenario when working with list-views and is happening both natively and in Titanium.Agreed with above. To add to this, the reason it is happening is because items that re-enter the visible area are re-rendered. This is also why a ListView can have thousands of rows and not crash a low-end device.
Thanks for the feedback. I tried it out and I found a solution. Store text value on change event and update the textfield on scrollstart. *Store text value*
*Update the textfield on scrollstart*events: { 'change': function(evt) { Ti.API.debug('change'); textFieldValue = evt.value; },list.addEventListener('scrollstart', function(e) { Ti.API.info('scrollstart'); section.updateItemAt(1, { template: 'myNotes', myNotes: { value: textFieldValue, } }); });