Creating multi-dimensional array and retrieving values from array
Hi,
I have multiple elements retrieved from JSON method, which I want to add to a array and then retrieve the values from it. I am not sure, how to achieve that. My current code is as below:
- var srcs = [];
var enumerator = this.pictures.getEnumerator();
- while (enumerator.moveNext()) {
- var currentItem = enumerator.get_current();
- var filename = currentItem.get_item('FileLeafRef');
- var dir = currentItem.get_item('FileDirRef');
- var caption1 = currentItem.get_item('ImgCaption1');
- var caption2 = currentItem.get_item('ImgCaption2');
- var captionsubtext = currentItem.get_item('SubText');
- }
- srcs.push(filename); // currently i have added only the filename. I would like to add caption1,caption2,captionsubtext as well to the array.
- addLis(srcs);
- }
- // currently only one argument is passed.
function addLis(s) {
var images = s,
- ul = $('#div2 > ul');
$.each(images, function (i, v) {
var li = $('<li><img src="' + v+ '"/></li>');
- ul.append(li);
- });
}
I want to pass the other arguments as well, and create "h2" html element based on caption for each image. How to achieve that?
Thanks