Katja Knecht
Posts: 0
Joined: Fri Jul 05, 2013 9:42 pm

What is the variable name of the counter value property in javascript?

Hi,

I am using a list service to retrieve a list of entries from my database and map them to a mobile list. In the response of the service I am mapping the ids of the entries to the counter value property of the list item (maybe not the most elegant solution but I do not want to use labels).

What I would like to know now is what the variable name of the counter value property is so that I can access it via javascript.
Is there an overview of all of the interface elements' properties and variable names available?
I have searched the help section but could not find anything like that.

Many thanks in advance!

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

What is the variable name of the counter value property in javascript?

The List is a jQuery Mobile component -- you can always check on http://jquerymobile.com for component docs

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

What is the variable name of the counter value property in javascript?

Hi Katja,

Just to add. You have no access to this counter. It's hidden inside of the mapping program code.

You can process all the received server data by running JavaScript code on service Success event. As a first parameter use the whole database response object.

Katja Knecht
Posts: 0
Joined: Fri Jul 05, 2013 9:42 pm

What is the variable name of the counter value property in javascript?

Many thanks for both of your answers! Extremely helpful!

If I cannot access the counter, then there is no use in hijacking it. So it has got to be labels after all.

Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

What is the variable name of the counter value property in javascript?

I have a similar situation. I have one list item in a grid. I cannot use labels in the list item, or hidden input, because I must use a split button. Putting a label or input on the list item is not compatible with a split button.

I am mapping the info I want displayed on the list items as a single variable from my REST service to the Text of the list item. However, when the button is clicked I need to access the ID, another field coming from my REST service, just like Katja asked about above.

Can you give me any suggestions on how to store the ID field, from my REST service, for each item so that I can retrieve it when the button is clicked. I tried putting a hidden input in the grid, and mapping the ID to that, but it isn't replicated by the mapping.

Help would be sincerely appreciated.

Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

What is the variable name of the counter value property in javascript?

I have come up with a solution. I will send the id in an html comment in the info mapped to the Text of the list item:
<!-- id=1234 --
and will use a RegEx in Javascript to extract it:
text.match(/id=(\d+) /);
var id = RegExp.$1

However, I cannot figure out the Javascript code to get the Text of the list item. Can you help with that? I have been searching the forum, but have not been successful. The name of the list is contact_list. The name of the list item is contact_list_item. The name of the button (on the split button) is contact_list_item_btn. The array from the REST service is mapped to contact_list_item. When I click contact_list_item_btn i need to get the value that was mapped to Text of contact_list_item.

Thank you.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

What is the variable name of the counter value property in javascript?

Hi Fred,

To get list-item text you should use next code on list-item "click" event handler:
pre
var listItem = jQuery(this);

var listItemText = listItem&#46;html();

console&#46;log(listItemText);
/pre

Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

What is the variable name of the counter value property in javascript?

Hi Illya,
That works very well when I click on the left part of the list item in a split button list. However I need to get the same information when I click on the button to the right of the split.

After examining the source code of the app running in a browser, it appears this may not be possible. Every button on the right side of the split in the list item has exactly the same id, name, and dsid.

I know it is against HTML5 rules to have more than one tag with the same id. They are supposed to be unique. So, I think there is a bug in how the code for the split button is created. The list items have ids that have sequentially incremented numbers appended to the name I gave the list item that the array was mapped to.

If the right hand button part of the list item had the same thing done when the list items are created from the mapping, then I know what code I'd use to get the text of the left part of the list. I'd use names for the left and right parts that are similar, then with a RegEx I'd modify the name of the button, and use it with your code to get the list item html.

Hopefully this bug can be fixed very soon. I am in desperate need of the code being created correctly, according to the HTML5 rules. :-)

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

What is the variable name of the counter value property in javascript?

Fred - thank you for reporting this. We'll research it additionally.

Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

What is the variable name of the counter value property in javascript?

This can be shortened to:
codevar listItemText = jQuery(this)&#46;html();/code

Return to “Issues”