[英]update image in web2py
I have a more special question. 我还有一个特别的问题。
It is really simple to display an image in an html tag. 在html标签中显示图像真的很简单。 I have done it by returning the sql file in a dict to the same named html file, which embed it in the tag with the following code:
我通过将dict中的sql文件返回到相同的html文件来完成此操作,并使用以下代码将其嵌入到标签中:
<img width="400px" src = "{{=URL('download_image', args = image_vid.file)}}" />
My problem is now, that i am really confused. 我的问题是,我现在真的很困惑。 I have an image database in model and i have made two buttons to switch between this.
我在模型中有一个图像数据库,并且我做了两个按钮可以在此之间切换。 The switching is simply done on this way
切换就是这样完成的
<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>
but i always have to refresh the browser tab to see the new chosen pic. 但我总是必须刷新浏览器标签才能看到新选择的图片。
I have seen that it would be possible to use java script for updating while the html is displayed without refreshing. 我已经看到,可以在显示HTML而不刷新的情况下使用Java脚本进行更新。 But i am confused.
但是我很困惑。 How it would be possible to access from javascript to the new chosen file overgiven from the controller functions?
如何从javascript访问控制器功能提供的新选定文件?
By the way, i am a noob and i hope that i have posed the question in a good way. 顺便说一句,我是菜鸟,我希望我以很好的方式提出了这个问题。
Thank you! 谢谢!
I suggest you use a javascript slider (there are tons in Codecanyon or Github). 我建议您使用JavaScript滑块(Codecanyon或Github中有很多)。 Normally you need to generate a template like this in Web2py:
通常,您需要在Web2py中生成这样的模板:
<div id="slider">
<img width="400px" src = "img1" />
<img width="400px" src = "img2"/>
<img width="400px" src = "img2"/>
...
</div>
Then you use something like this at the bottom of your template: 然后,在模板底部使用以下代码:
<script type="text/javascript">
$(window).load(function() {
$('#slider').activate();
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.