Page 1 of 1

how do I reference a single label value in a listitem?

Posted: Thu Sep 03, 2015 1:58 am
by scott smiley

I have a list called MessageList with 4 labels. id, firstname and lastname and messagetext. id is a hidden label. I want to test to see if id matches my saved localstorage value and change the property of only that listitem row.

So - some of the listitems will have a different background color to emphasis them.

I've looked at jQuery iteration examples and none of them reference a listitem that has multiple labels. I also don't see how to view the source in Chrome developer tools so I know what the appropriate tags are for the 4 embedded label ids.

Can you help me with an example that show how to check a listitem value when multiple label controls are in a single listitem?

Thanks!


how do I reference a single label value in a listitem?

Posted: Thu Sep 03, 2015 11:15 am
by Serhii Kulibaba

Hello Scott,

Do you need to read listitem's labels? You can do it with JS on the listitem's click event:

var value = $(element).find("[name=labelName]").text();


how do I reference a single label value in a listitem?

Posted: Thu Sep 03, 2015 4:53 pm
by scott smiley

If i want to reference after page service success event how do i loop through and read all labels in all listitems? I want to change background properties of those listitems that have a specific value in order to highlight them.


how do I reference a single label value in a listitem?

Posted: Fri Sep 04, 2015 1:28 pm
by Serhii Kulibaba

Please use this JS for changing background of all labels from the listitem:
pre$(element).find("[data-role=appery_label]").css("background-color","red");/pre


how do I reference a single label value in a listitem?

Posted: Wed Sep 09, 2015 1:29 am
by scott smiley

Can you tell me how to format your suggested code for this messageList? I want to find the messageitem_1 where value of userid = 2 and change the background color to red. There are 3 labels on a listitem and one of them is userid. I don't know if element is id, dsid, etc.. ( I cut out the other two labels for readability)

<!-- messageitem_1
<li id="Home_messageitem_1" name="messageitem_1" dsid="messageitem_1" data-icon="carat-r"
class="Home_messageitem_1"
<div class="ui-li-static-container ui-btn" tabindex="10"
<!-- userid
<div name="userid" id="Home_userid" dsid="userid" data-role="appery_label" class="Home_userid"
<

Code: Select all

             </ul 

--


how do I reference a single label value in a listitem?

Posted: Fri Sep 11, 2015 8:45 pm
by Serhii Kulibaba

You have to use JS like this:
preif ($(element)&#46;find("[name="userid"]")&#46;text() == "2"){
$(element)&#46;find("[name="messageitem_1]")&#46;css("background-color","red");
}/pre