[英]rails turbolinks onerror javascript
I want to hide an image when the link of the image is broken (404 not found). 我希望在图像链接断开时隐藏图像(404未找到)。 When i trigger an
onerror:hideImage(this)
on my image it works once and then because of Turbolinks, it hides all the images after a refresh. 当我触发一个
onerror:hideImage(this)
在我的图像上它工作一次然后因为Turbolinks,它在刷新后隐藏所有图像。 Is there a solution? 有解决方案吗?
function hideImage(source){
source.hide();
}
Thanks 谢谢
Ok, found the solution: 好的,找到了解决方案:
add onerror:"this.style.display='none'"
to your image_tag and it's done! 添加
onerror:"this.style.display='none'"
到你的image_tag就完成了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.