Page 1 of 1
set image visible when in an array
Posted: Sat Nov 07, 2015 1:14 pm
by David wyatt
Hi,
I have an array that contains an image. I want to be able to show only certain array images. Ive tried the following
var arr = Apperyio("image");
var i = Apperyio("array").text();
arr.show();
and
Apperyio('arr').show();
but I cant get it to work.
Any hep would be much appreciated
thanks
Dave
set image visible when in an array
Posted: Mon Nov 09, 2015 9:24 am
by Serhii Kulibaba
Hello David,
I am sorry, not sure I understand you correctly. Please specify your question.
Do you an array of the images with the name "image", which were areated with the mapping? If so - please use code below:
prevar arr = $("[name=image]");/pre
set image visible when in an array
Posted: Mon Nov 09, 2015 1:54 pm
by David wyatt
Hi Sergy,
that's correct, I want to be able to hide/show selected images from the array. but when I try
var arr = $("[name=image]");
var i = Apperyio("array").text();
Apperyio("arr").show();
along with
arr.show();
or
Apperyio(arr).show();
nothing happens
thank you
set image visible when in an array
Posted: Wed Nov 11, 2015 8:16 am
by Serhii Kulibaba
Please use JS below:
prevar i = parseInt(Apperyio("array").text());
$(arr).show();/pre
set image visible when in an array
Posted: Wed Nov 11, 2015 5:49 pm
by David wyatt
Thank you Sergiy, works a treat
set image visible when in an array
Posted: Thu Mar 10, 2016 10:51 am
by John7876801
Hello team,
I am facing the exact same issue. The only thing I don't understand in the approach outlined above is how to get the index i of the array element. In particular, what does actually "array" designate? Can you elaborate on that? Thanks!
john
set image visible when in an array
Posted: Thu Mar 10, 2016 9:40 pm
by Serhii Kulibaba
Hello John,
Please clarify, what do you mean writting "the index i of the array element"?
what does actually "array" designate?
In the JS code above it is a simple label with the name ="array"
set image visible when in an array
Posted: Fri Mar 11, 2016 6:17 am
by John7876801
I mean the array item on which I want to take an action.
here's actually my problem: I map an array to a grid containing various components, including an image. The array item i doesn't always contain an image, and I would like to hide the image component in the grid when this is the case. So I included the this simple javascript in the mapping: Appery("image").hide(). However, this only affects the first item (i=0). So I assumed that the code should be enhanced with a reference to each individual array item ("i").
I hope it clarifies!
Best,
john
set image visible when in an array
Posted: Fri Mar 11, 2016 5:03 pm
by Serhii Kulibaba
You have to hide current image, but Appery("image") returns only first element, which was created with mapping. Please use JS code:
preelement.hide();/pre
instead of :
preAppery("image").hide();/pre
set image visible when in an array
Posted: Sun Mar 13, 2016 6:28 pm
by John7876801
Great, thank you Sergiy! Sometimes it's the little things...