Page 2 of 2

Mapping an array to Checkboxgroup

Posted: Sat May 23, 2015 1:17 pm
by Paul Medawar

Sorry, just noticed that the full logs were not pasted correctly

Here they are again

the following appears when I have ["2"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []

when i have ["4"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []
[Log] check box[2] =
[Log] []
[Log] check box[3] =
[Log] []

they both look and work fine...but when I have more than one number in the array, for example ["2","4"}

nothing appears in the console and none of the checkboxes are checked


Mapping an array to Checkboxgroup

Posted: Sat May 23, 2015 1:19 pm
by Paul Medawar

Sorry, just noticed that the full logs were not pasted correctly

Here they are again

the following appears when I have ["2"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []

when i have ["4"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []
[Log] check box[2] =
[Log] []
[Log] check box[3] =
[Log] []

they both look and work fine...but when I have more than one number in the array, for example ["2","4"}

nothing appears in the console and none of the checkboxes are checked


Mapping an array to Checkboxgroup

Posted: Sat May 23, 2015 1:26 pm
by Paul Medawar

Sorry just seen the log didn't paste fully...here's screenshots instead

Image

Image


Mapping an array to Checkboxgroup

Posted: Mon May 25, 2015 2:47 am
by Yurii Orishchuk

Hi Paul,

That means you don't have checkboxes with such names.

Use following JS code to log these names too:

pre

var onDelay = function(){
for(var i = 0; i < data&#46;channels; i++){
var checkBox = Apperyio("mobilecheckboxgroup_10")&#46;find('[value='+data&#46;channels+']');
console&#46;log("check box[" + i + "] with name " + data&#46;channels + " = ");
console&#46;log(checkBox);
checkBox&#46;prop('checked', true)&#46;refresh();
}
};
window&#46;setTimeout(onDelay, 100);

/pre

Regards.


Mapping an array to Checkboxgroup

Posted: Mon May 25, 2015 7:43 am
by Paul Medawar

Hi Yurii,

I found that changing

for(var i = 0; i < data.channels; i++){

to

for(var i = 0; i < 4; i++){

has allowed the response to map to the checkboxes, when there is more than one number in the array.

does this appear like an adequate solution?


Mapping an array to Checkboxgroup

Posted: Tue May 26, 2015 12:27 am
by Yurii Orishchuk

Hi Paul,

It's not good to hardcore array length.

Sorry i see there was error in given before code.

here is a corrected:

pre

var onDelay = function(){
for(var i = 0; i < data&#46;channels&#46;length; i++){
var checkBox = Apperyio("mobilecheckboxgroup_10")&#46;find('[value='+data&#46;channels+']');
console&#46;log("check box[" + i + "] with name " + data&#46;channels + " = ");
console&#46;log(checkBox);
checkBox&#46;prop('checked', true)&#46;refresh();
}
};
window&#46;setTimeout(onDelay, 100);

/pre

Regards.


Mapping an array to Checkboxgroup

Posted: Tue May 26, 2015 6:44 am
by Paul Medawar

:) Thanks Yurii, great as always, and a lot of the advice you have given on other peoples questions has helped me get the most out Appery!

Not sure if you guys will be covering this in the upcoming update, but the platform keeps hanging everytime I click cancel in mapping.

thanks again for your help, and an amazing product