1

I have a issue which is hurting my head cant think how to do it. I have the following feed.

[{
    "title": "thumb_36cr8350.jpg",
    "url": "http://example.com/s3images/thumb_36cr8350.jpg",
}, {
    "title": "large_36cr8352.jpg",
    "url": "http://example.com/s3images/large_36cr8350.jpg",

}, {
    "title": "thumb_36cr8358.jpg",
    "url": "http://example.com/s3images/thumb_36cr8358.jpg",
}, {
    "title": "large_36cr8360_a.jpg",
    "url": "http://example.com/s3images/large_36cr8358.jpg",

}]

which i am looping through

var thumb = "<ul id='thumbs'>";
$.each(response, function (i, item) {
    var params = baseName(item.title).split("_");
    if (params[0] === 'thumb') {
        thumb += '<li><a class="group1" href="{this need to be the large thumb}"><img src="' + item.url + '" width="75" height="75"/></a></li>';
    }
});
thumb += "</ul>";
$('.conatiner').html('<div id="wrap">' + thumb + '</div>');

function baseName(str) {
    var base = new String(str).substring(str.lastIndexOf('/') + 1);
    if (base.lastIndexOf(".") != -1)
        base = base.substring(0, base.lastIndexOf("."));
    return base;
}

I need to somehow push the large pic into the href of the list for the Lightbox effect.

Cannot for the life of me think how to do this.

Any help please

4

1 回答 1

1

告诉我这是否是您正在寻找的:

var thumb = "<ul id='thumbs'>";
$.each(response, function (i, item) {
    var params = baseName(item.title).split("_");
    if (params[0] === 'thumb') {
        thumb += '<li><a class="group1" href="#{url}"><img src="' + item.url + '" width="75" height="75"/></a></li>';
    } else {
        thumb = thumb.replace("#{url}", item.url);
    }
});
thumb += "</ul>";
$('.conatiner').html('<div id="wrap">' + thumb + '</div>');

function baseName(str) {
    var base = new String(str).substring(str.lastIndexOf('/') + 1);
    if (base.lastIndexOf(".") != -1)
        base = base.substring(0, base.lastIndexOf("."));
    return base;
}
于 2013-07-08T13:44:20.760 回答