Page 1 of 1

List Element Referencing

Posted: Tue May 29, 2012 12:17 pm
by Chris2656882

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.


List Element Referencing

Posted: Tue May 29, 2012 3:44 pm
by maxkatz

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.


List Element Referencing

Posted: Tue Jun 05, 2012 8:11 pm
by Chris2656882

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?


List Element Referencing

Posted: Wed Jun 06, 2012 3:48 am
by maxkatz

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


List Element Referencing

Posted: Wed Jun 06, 2012 10:34 am
by Chris2656882

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.


List Element Referencing

Posted: Wed Jun 06, 2012 1:21 pm
by maxkatz

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


List Element Referencing

Posted: Wed Jun 06, 2012 1:31 pm
by Chris2656882

Yes it did. Thanks!