Chris2656882
Posts: 0
Joined: Fri May 11, 2012 3:47 pm

List Element Referencing

When inputting a services request into a list, how does one indicate that an item should be a category header instead of a regular list item?

When coding JQuery Mobile manually, I know it involves making the LI element include
data-role='list-divider' role='heading'.

However, how do I refer to the current element (id) using custom javascript? Referring to the dsid will point to every element in the list since they share the same value.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

List Element Referencing

When you do mapping, and inside the iteration you can find the list value which has to be a header. From there you can run the custom JavaScript to make it header.

Chris2656882
Posts: 0
Joined: Fri May 11, 2012 3:47 pm

List Element Referencing

Can you please expand upon your answer?

How would I reference that specific list entry in Javascript to tell it to become a header? I cannot use Tiggr('list_name') as that refers to the entire list, not the specific entry. List entry id's seem to have an id in the format of " j_194_0". How do I reference the entry in javascript before the list is even populated?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

List Element Referencing

It could be something like this:

code
if (value == 'Anna'){
var listItem = element.parent();
listItem.attr('data-role', 'list-divider');
listItem.attr('role', 'heading');

Code: Select all

listItem.removeClass(); 
listItem.addClass('mobilelistitem1 ui-li ui-li-divider ui-bar-b'); 

element.next().remove(); 

}
/code

You would run this code in mapping and above I make a divider item which has value of 'Anna'.

Image

Chris2656882
Posts: 0
Joined: Fri May 11, 2012 3:47 pm

List Element Referencing

Great! Thanks Max, that helped a great deal!

However, one issue that I fixed:
• It behaves as a normal list item. It should not be clickable. However, I was able to fix this with some custom js in the events panel.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

List Element Referencing

The last line should remove the children, which is the span for icon.

Chris2656882
Posts: 0
Joined: Fri May 11, 2012 3:47 pm

List Element Referencing

Yes it did. Thanks!

Return to “Issues”