DataZombies/jQTouch — Issue #84: Manually Called List Index
Author: PoZel
Created: 2011-12-09 16:46:09+00:00
State: open

Hi,

Noticed something trying to adapt code to work for me.

I have a list that is populated through javascript from a html5 database (local storage). I only want the list to be indexed once it has been populated from the database javascript call.

As such, I removed the "indexed" class from the wrapper div (to prevent a list index being created before the list is populated) and instead manually call initListIndex('page') once the db call completes.

I noticed that this wasn't creating adding the IDs to the separators in the list and did some debugging to see why that was.

It comes down to line 239:

```javascript
if ($page.children().hasClass('indexed') && !$page.children().hasClass('listIndex')) {
```

The code to index a single page check that there is an element with class "indexed". As far as I can see, you can only end up working on a single page if you call it manually or on "pageInserted". As "pageInserted" checks if there is a child with ".indexed" (line 284), this check on line 239 seems redundant and results in a manually requested index failing.

It is somewhat likely that I have overlooked something here, but if I haven't, I think logically, line 239 can be changed to the following, which enables manual calling of indexing:

```javascript
if (!$page.children().hasClass('listIndex')) {
```

I look forward to hearing your thoughts on this.

Thanks again!!