Modal is "remembering" code from previous modals
The Problem is you only set new src
values but the image-elements themselves (which are hidden/displayed after a click on the thumbnails) are still in the same state as in the modal before.
I got it working by triggering a click on the first thumb when the modal opens:
open: function() {
correspondingModal.find("#thumb_1").parent("a").trigger("click");
}
Updated Fiddle
Could be a hackjob. But have a try. Add this piece of code in the click
of .info
function:
$(".content img").hide(0, function () {
$(".image_1").show();
});
This effectively "resets" the images:
Fiddle: http://jsfiddle.net/praveenscience/nLhcejsz/2/
I changed the order of your inital .ready() functions and attempted to save the contents of all modals and reload them when Custombox is closed.
EDIT: The non-loading images has been resolved by loading the content on both the open()
and close()
functions of Custombox.
Grab initial modal content:
$(".modal").each(function () {
window['reset' + $(this).attr('id')] = $(this).find('.content').html();
});
Load modal at Custombox open():
open: function(){
$(".modal").each(function () {
$(this).find('.content').html(window['reset' + $(this).attr('id')]);
});
}
Reload modal at Custombox close():
close: function(){
$(".modal").each(function () {
$(this).find('.content').html(window['reset' + $(this).attr('id')]);
});
}
UPDATED FIDDLE: http://jsfiddle.net/nLhcejsz/6/
This should now behave as you are requesting, the modal forgets which thumbnail was clicked and resets accordingly.