I am trying to upload some images and adding them div container.
My question is there are more than 1000’s of images to upload so if I upload them to the same div scrollbar is shown but it dosent looks good to my users.So I would like to add pagination to those images.
I found this Site(example 5) which suits my needs and In that it is actually containing a simple div and the structure is as follows:
<div id="paginationdemo" class="demo">
<h1>Demo 5</h1>
<div id="p1" class="pagedemo _current" style="">Page 1</div>
<div id="p2" class="pagedemo" style="display:none;">Page 2</div>
<div id="p3" class="pagedemo" style="display:none;">Page 3</div>
<div id="p4" class="pagedemo" style="display:none;">Page 4</div>
<div id="p5" class="pagedemo" style="display:none;">Page 5</div>
<div id="p6" class="pagedemo" style="display:none;">Page 6</div>
<div id="p7" class="pagedemo" style="display:none;">Page 7</div>
<div id="p8" class="pagedemo" style="display:none;">Page 8</div>
<div id="p9" class="pagedemo" style="display:none;">Page 9</div>
<div id="p10" class="pagedemo" style="display:none;">Page 10</div>
<div id="demo5">
</div>
</div>
And it’s script is :
<script type="text/javascript">
$(function () {
$("#demo5").paginate({
count: 10,
start: 1,
display: 7,
border: true,
border_color: '#fff',
text_color: '#fff',
background_color: 'black',
border_hover_color: '#ccc',
text_hover_color: '#000',
background_hover_color: '#fff',
images: false,
mouse: 'press',
onChange: function (page) {
$('._current', '#paginationdemo').removeClass('_current').hide();
$('#p' + page).addClass('_current').show();
}
});
});
</script>
This is how I upload Images dynamically
$.each(data.result, function (index, file) {
$('#p1').append("<img class='LoadclickImage' align='left' style='height:48px;width:75px;' src='Uploads/" + file.name + "' width='75' height='50' href='Uploads/" + file.name + "' >");
});
Now what happens is if I add Images they are appending to the same page and the list is going on increasing so how do I limit the images to the specific div and add them to the next page by creating it dynamcally as I don’t know how many mages they will upload and try to append them to the next page if they exceed.
And if anyone has a better and the simplest idea they can share.I love to hear them 🙂
Here is how I would solve it (but assuming all the images are going to be loaded at the same time in just one ajax request).
Javascript:
And here is the live demo: http://jsfiddle.net/protron/gbzsR/7/