更新web2py中的图像

update image in web2py

本文关键字:图像 web2py 更新      更新时间:2023-09-26

我有一个更特别的问题。

在html标签中显示图像非常简单。我通过将dict中的sql文件返回到同一个命名的html文件来完成这一操作,该文件使用以下代码将其嵌入到标签中:

<img width="400px" src = "{{=URL('download_image', args = image_vid.file)}}" /> 

我现在的问题是,我真的很困惑。我在模型中有一个图像数据库,我做了两个按钮来切换。切换只是通过这种方式完成的

<button name="previousButton" type="button"
    value="Überraschung1" onclick="{{if session.currentImVidID >  session.currentLenImVid:}}
                                  {{session.currentImVidID = session.currentImVidID - 1}}   
                                  {{else:}}
                                  {{session.currentImVidID = session.currentLenImVid - 1}}
                                  {{redirect(URL('show_image_video'))}}
                                  {{pass}}">                                  
        previous file
</button>

但我总是需要刷新浏览器选项卡才能看到新选择的图片。

我已经看到,在不刷新html的情况下显示html时,可以使用java脚本进行更新。但我很困惑。如何从javascript访问控制器函数过度提供的新选择文件?

顺便说一句,我是一个傻瓜,我希望我以一种好的方式提出了这个问题。

谢谢!

我建议您使用javascript滑块(Codecanyon或Github中有很多)。通常你需要在Web2py:中生成这样的模板

<div id="slider">
    <img width="400px" src = "img1" />
    <img width="400px" src = "img2"/>
    <img width="400px" src = "img2"/>
    ...
</div>

然后你在模板的底部使用这样的东西:

<script type="text/javascript">
$(window).load(function() {
    $('#slider').activate();
});
</script>