2013-10-25 55 views
1

我想要在圖像鏈接斷開時隱藏圖像(404未找到)。 當我在我的圖片上觸發onerror:hideImage(this)時,它只會起作用一次,然後因爲Turbolinks,它會在刷新後隱藏所有圖像。 有沒有解決方案?rails turbolinks onerror javascript

function hideImage(source){ 
    source.hide(); 
} 

感謝

回答

3

好了,找到了解決辦法:

添加onerror:"this.style.display='none'"您IMAGE_TAG它完成!

+0

這有幫助。感謝分享。 – LondonGuy