Page 4 of 6

Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 1:41 pm
by Alena Prykhodko

As to the second - we'll figure out and update.


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 1:59 pm
by Priyanka Patel

You mean this method here?

var short_name = localStorage.getItem("short_name");
if (!short_name) {
// we have new item, so we get short_name as first value
// next value will be Name
localStorage.setItem("short_name", value);
return value;
} else {
// we already processed short_name
// next value will be short name for new item, so do cleaning
localStorage.setItem("short_name", '');
return short_name + ' - ' + value;
}

Sorry, what are you referring to as 'second' above?


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:02 pm
by Priyanka Patel

If I am meant to use the code above, am a bit confused as to whether I need to set a local storage variable first? Also am a bit confused about what short_name and value refers to above.

Anychance, you could give me a code example using my variables please?


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:03 pm
by Alena Prykhodko

Sorry, yes, I'm talking about this post https://getsatisfaction.com/apperyio/...

Just use that code without changes.


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:09 pm
by Alena Prykhodko

You need to add JS on Response (checkboxItem):

codevar short_name = localStorage.getItem("short_name");
if (!short_name) {
// we have new item, so we get short_name as first value
// next value will be Name
localStorage.setItem("short_name", value);
return value;
} else {
// we already processed short_name
// next value will be short name for new item, so do cleaning
localStorage.setItem("short_name", '');
return short_name + ' - ' + value;
}/code

And connect ItemName and Text in checkboxlabel as well.

Like on the pic:
Image


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:10 pm
by Priyanka Patel

"without changes"
Isn't the short_name and name variable referring to the fields that the original problem was referring to? As in, they wanted to display a shortname and name in one field.

My variable names are different (ItemName and carbonUnits), so how would the above code work in my instance?


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:17 pm
by Priyanka Patel

Yeap, just did that.

I only get the itemName though, no carbonUnits beside it.


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:20 pm
by Alena Prykhodko

Do you have carbonUnits mapped?


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:21 pm
by Alena Prykhodko

No, "short_name" it's function, variable it's value


Mapping multiple responses from a service to the same component

Posted: Sun Aug 25, 2013 2:23 pm
by Priyanka Patel

Currently, I have tried mapping carbonUnits to text in checkboxlabel along with ItemName. In that case, the name gets overwritten and only the carbonUnits are displayed.