1

In this fiddle

when you click on next then new images are loaded.But the new images are loaded from internet.

In my app all the images are located in img/image folder and the image names are 1.jpg,hi.png etc

So how can I show the images when I click on next

I thought i will modify var srcs = [ 'http://lorempixel.com/150/100/city', 'http://lorempixel.com/150/100/sports' ]; with var srcs = [ 'img/image/1.jpg', 'img/image/hi.png' ];

But if I do this way then the problem will be I have to change var srcs if I add a new image to the folder

For example If after a later time I add 3.jpg then I have to manually var srcs = [ 'img/image/1.jpg', 'img/image/hi.png','img/image/3.jpg' ];

rocking
  • 4,729
  • 9
  • 30
  • 45

1 Answers1

0

Here an example that can help you, it's not optimal but works http://jsfiddle.net/PrVRq/ :

$('.images').on('loaded', function () {// load an image}

try to load the next image

img.load(function () {    
    $('.images').append(img);
    $('.images').trigger('loaded');
});

if the image is loaded trigger the loaded event to load another one.

Rida BENHAMMANE
  • 4,111
  • 1
  • 14
  • 25
  • Thanks for the answer.Actually my requirement is when I click on next then new 2 images will appear and the old 2 images will disappear – rocking Feb 13 '14 at 11:24
  • Thanks for the answer.I am new to backbone and so if you dont mind can I ask your email id? – rocking Feb 13 '14 at 11:44
  • If you have any question about Backbone, just ask it in SO and I or someone else will help you for sure ;) – Rida BENHAMMANE Feb 13 '14 at 11:48
  • I am a beginner is javascript and backbone.I will not ask you write codes but I need some ideas how to do.And you know SO is not the right place to ask for ideas.If I post question asking for ideas then my post will be closed as off the topic.Unless I have codes,I can not post in SO.Thanks – rocking Feb 13 '14 at 12:08