【发布时间】:2017-06-28 15:55:25
【问题描述】:
我正在使用 jsf 2.2 primefaces 6.0,并且我已经实现了使用 Galleria primefaces 组件显示图像的解决方案。现在的问题是我正在尝试找到通过使用 javascript 的按钮从 Galleria 下载图像的解决方案。( remarque我是一个初学者程序员,从未使用过js)
stackoverflow 的一个成员给了我一个代码,但它不起作用或者我无法实现它。
这里是xhtml代码:
<p:galleria value="#{demandeBean.demandeSelectionnee.images}"
panelWidth="500" panelHeight="313" showCaption="false"
autoPlay="false" var="image">
<p:graphicImage
value="http://localhost:18080/openCars/images/#{image}"
width="500" height="313" />
</p:galleria>
这里建议使用 js 解决方案:
<script type="text/javascript">
function download() {
$('.ui-galleria-panel img').each(function() {
$(this).after( "<a href='"+ $(this).attr('src') +"' download='nameOfImage.jpg' class='ui-button' style='position: absolute;right: 0;top: 0; padding: 5px 10px;background:rgba(255,255,255,0.7);'><i class='fa fa-download'></i></a>" )
});
</script>
【问题讨论】:
-
" 但它不起作用或我无法实现它。" 这就像描述问题的最终用户。像开发人员一样接近它。发生了什么事,你看到按钮出现了吗?函数被调用了吗?请缩小问题范围。在没有我们要求各种澄清的情况下,现在可以广泛/不清楚
标签: javascript primefaces jsf-2.2