Leonardo Valentin Zeferino
Posts: 0
Joined: Fri May 29, 2015 2:07 pm

Using instead of in html screen code

Perfect, Illya!!

Just one more question.

code
"source": "$['count_likes']",
"target_transformation": function(value, element) {
return "<span>" + value + "</span>&quot
},
"target": "$['mobilegrid_14']['n_likes_html:rawHtml']"
/code

I tried the code above with success but I'd like to use others data together.
How the result of rest service is a list/array of values, I think that I have to get a low level (i). When I tried the code below, the app shows "undefined".

code
"source": "$['count_likes']",
"target_transformation": function(value, element) {
var data = restservice1&#46;response&#46;body;
$&#46;each(this&#46;data, function(index, val) {
return "<span>" + data&#46;count_likes + " " + data&#46;count_comments +"</span>&quot
});
},
"target": "$['mobilegrid_14']['n_likes_comments_html:rawHtml']"
/code

How can I access one low level of the response.body?

I tried the code below too without success.

code
"source": "$['count_likes']",
"target_transformation": function(value, element) {
var data = restservice1&#46;response&#46;body;
$&#46;each(this&#46;data, function(index, val) {
return "<span>" + data&#46;count_likes + " " + data&#46;count_comments +"</span>&quot
});
},
"target": "$['mobilegrid_14']['n_likes_comments_html:rawHtml']"
/code

Thanks!

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

Using instead of in html screen code

Leonardo -

It looks like your code returns only one line of code, you should use something like this:

pre
code
&#46;&#46;&#46;
var data = restservice1&#46;response&#46;body;
var sHtml = "&quot
$&#46;each(data, function(index, val) {

Code: Select all

 sHtml += "<span>" + data[index]&#46;likes + "</span>&quot 
 sHtml += "<span>" + data[index]&#46;comments + "</span>&quot 

}
return sHtml;

/code
/pre

Leonardo Valentin Zeferino
Posts: 0
Joined: Fri May 29, 2015 2:07 pm

Using instead of in html screen code

Hi Illya!!

Thanks for helping me!
The code that you sent me isn't useful because I do the loop with the mapping.

code"source": "$['count_likes']",
"target_transformation": function(value, element) {
var count_comments = Apperyio('n_comments_lb')&#46;text();
return "<span>" +value + " " + count_comments +"</span>&quot
},
"target": "$['mobilegrid_14']['n_likes_comments_html:rawHtml']"
/code

I tried the code above. It worked. But the problem is if I have 2 or more labels n_comments_lb (because of the codes below generated from loop), it loses itself and shows me the wrong value.

html code:
code<div name="n_comments_lb" id="feed_n_comments_lb_0" dsid="n_comments_lb_0" data-role="appery_label" dsrefid="n_comments_lb" idx="0">1<>
/code
and
code<div name="n_comments_lb" id="feed_n_comments_lb_1" dsid="n_comments_lb_1" data-role="appery_label" dsrefid="n_comments_lb" idx="1">0<>
/code

How can I get the specific label id/name of the iteration 0, 1, 2,... something like below?

codevar count_comments = Apperyio('n_comments_lb_0')&#46;text();
/code

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

Using instead of in html screen code

Hi Leonardo -

You are using mapping to the entity code "source": "$['count_likes']" /code
but it should be mapped to the array something like this: code "source": "$['body'][0]"/code

But as I has told you before, your implementation is deeply involved in editing the source files and code structure of our code generation part of our visual builder. And such cases are lies outside the scope of our standard support.

Leonardo Valentin Zeferino
Posts: 0
Joined: Fri May 29, 2015 2:07 pm

Using instead of in html screen code

Hi Illya!

Actually I'm using the entity code"source": "$['count_likes']"/code because I'm mapping a local storage variable.

Look

Image

Image

Is there any other option to do this mapping or any other option to read the variable code$/code in the code"source": "$['count_likes']"/code?

Thanks!

Leonardo Valentin Zeferino
Posts: 0
Joined: Fri May 29, 2015 2:07 pm

Using instead of in html screen code

Hi Illiay!!

I solved it.

code
{
"source": "$['_id']",
"target_transformation": function(value, element) {

var dataString = localStorage&#46;getItem("checkin");
var data = JSON&#46;parse(dataString);

for (var k = 0; k < data&#46;length; k++){
if ( data[k]&#46;_id === value ){
var count_comments = data[k]&#46;count_comments;
var count_likes = data[k]&#46;count_likes;
}
}

var sHtml = "&quot
sHtml += "<span>"+ count_comments +"</span>&quot
sHtml += "<span>"+ count_likes +"</span>&quot
return sHtml;

},
"target": "$['mobilegrid_14']['n_likes_lb:rawHtml']"

},
/code

Thanks!

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

Using instead of in html screen code

Great! I'm glad to hear that!

Return to “Issues”