David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

set image visible when in an array

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

set image visible when in an array

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

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

set image visible when in an array

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

set image visible when in an array

Please use JS below:

prevar i = parseInt(Apperyio("array").text());
$(arr).show();/pre

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

set image visible when in an array

Thank you Sergiy, works a treat

John7876801
Posts: 0
Joined: Thu Nov 19, 2015 2:04 pm

set image visible when in an array

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

set image visible when in an array

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"

John7876801
Posts: 0
Joined: Thu Nov 19, 2015 2:04 pm

set image visible when in an array

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

set image visible when in an array

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

John7876801
Posts: 0
Joined: Thu Nov 19, 2015 2:04 pm

set image visible when in an array

Great, thank you Sergiy! Sometimes it's the little things...

Return to “Issues”