When the page is loading for the first time, I need to check if there is an image in image_array
and load the last image.
(第一次加载页面时,我需要检查image_array
是否有图像并加载最后一张图像。)
Otherwise, I disable the preview buttons, alert the user to push new image button and create an empty array to put the images;
(否则,我将禁用预览按钮,提醒用户按下新图像按钮,并创建一个空数组来放置图像;)
The problem is that image_array
in the else
fires all time.
(问题是, image_array
在else
火灾所有的时间。)
If an array exists - it just overrides it, but alert doesn't work. (如果存在数组-它将覆盖它,但是警报不起作用。)
if(image_array.length > 0)
$('#images').append('<img src="'+image_array[image_array.length-1]+'" class="images" id="1" />');
else{
$('#prev_image').attr('disabled', 'true');
$('#next_image').attr('disabled', 'true');
alert('Please get new image');
var image_array = [];
}
UPDATE Before loading html, I have something like this:
(更新在加载html之前,我有类似以下内容:)
<?php if(count($images) != 0): ?>
<script type="text/javascript">
<?php echo "image_array = ".json_encode($images);?>
</script>
<?php endif; ?>
ask by user1564141 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…