Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Change only that list item background if the list service return different response from storage variable

I've used a list service to list objects out
What I want to achieve is when the label in that list item is not equal to a local storage variable, the background of that list item will change (only that list item)
(I know how to set the background - Appery('mobilelistitem_197').css('background-image','url("http://i.imgur.com/Jw2JC0H.png")');

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Change only that list item background if the list service return different response from storage variable

Hello Mark,

You can run custom JavaScript to check the values on "Value change" event and depending on result change background.

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Change only that list item background if the list service return different response from storage variable

Sorry I don't understand,
The code I've used:
codevar flip = Apperyio('mobilelabel_205').text();
var user = Apperyio.storage.user_name.get();
if (flip != user){
Appery('mobilelistitem_197').css('background-image','url("http://i.imgur.com/Jw2JC0H.png")');
}/code
Image
It only change the first item rather than all the items that meet the requirement

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Change only that list item background if the list service return different response from storage variable

Hi Mark,

It's better to use following solution:

  1. In Success mapping. Add link from $ - listItem/grid.

  2. Click JS on this link.

  3. Use following JS code:

    pre

    if(value.someVariable == "incomming"){
    jQuery(element).addClass("incomming");
    }
    else{
    jQuery(element).addClass("outcomming");
    };

    /pre

    Then you can use "incomming" and "outcomming" class to separate view in accordance with your requirements. For example you can set background, margins, paddings etc...

    Regards

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Change only that list item background if the list service return different response from storage variable

Hi Yurii,
So I need to create a new CSS script and create these two new classes,
Right?
value.someVariable should I replace with anything?

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Change only that list item background if the list service return different response from storage variable

Image
Here is a screenshot,
The list service response include "user_name" which I need to use for classifying whether should the background be 1 or 2
But how should I define it by using JS?
Thank you!

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Change only that list item background if the list service return different response from storage variable

Please Ignore the comment above.
Image
There are no background changing happen to the listitems.
My CSS code
codebackground1{
background-image:url(http://i.imgur.com/Jw2JC0H.png);
}
background2{
background-image:url(http://i.imgur.com/5hftupF.png);
}
/code
Is there any error in my code?Because I use weinre debugger and everything seems ok.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Change only that list item background if the list service return different response from storage variable

Hi Mark,

You forget dot before class names in the CSS rules:

pre

.background1{
background-image:url(http://i.imgur.com/Jw2JC0H.png);
}
.background2{
background-image:url(http://i.imgur.com/5hftupF.png);
}

/pre

Details: http://www.w3schools.com/css/css_sele...

Regards

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Change only that list item background if the list service return different response from storage variable

Any progress?
I found out when I disable the background of
.ui-body-b, .ui-page-theme-b .ui-body-inherit, html .ui-bar-b .ui-body-inherit, html .ui-body-b .ui-body-inherit, html body .ui-group-theme-b .ui-body-inherit, html .ui-panel-page-container-b (flat-ui.css)&
.ui-body-b, .ui-page-theme-b .ui-body-inherit, html .ui-bar-b .ui-body-inherit, html .ui-body-b .ui-body-inherit, html body .ui-group-theme-b .ui-body-inherit, html .ui-panel-page-container-b (jqm.css)
the background image appear

Return to “Issues”