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

Mapping multiple responses from a service to the same component

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

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Mapping multiple responses from a service to the same component

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?

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Mapping multiple responses from a service to the same component

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?

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

Mapping multiple responses from a service to the same component

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

Just use that code without changes.

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

Mapping multiple responses from a service to the same component

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

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Mapping multiple responses from a service to the same component

"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?

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Mapping multiple responses from a service to the same component

Yeap, just did that.

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

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

Mapping multiple responses from a service to the same component

Do you have carbonUnits mapped?

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

Mapping multiple responses from a service to the same component

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

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Mapping multiple responses from a service to the same component

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.

Return to “Issues”