我嘗試了通常的操作來更改斷開的鏈接圖標(請參見下文),但它們似乎並未在我的Ember應用程序中工作。在Ember中更改斷開的鏈接圖標
目前,模型從外部API獲取數據。其中一條數據是鏈接網址。此鏈接URL(product_link
)被插入到該模板,具體地在這一點:
<img {{bind-attr src=product_link}} />
這是一個車把{{#each}}
迴路的一部分。有幾個鏈接指向死鏈接,我現在沒有辦法修復這些網址。我想用我自己的一個替換通用的斷開圖標鏈接。我怎樣才能做到這一點?
事情我已經嘗試:
<img {{bind-attr src=favorite.product_image onError="this.onerror=null;this.src='/img/error.png';"}} />
//still shows the standard broken image icon
-
$('img').error(function(){
$(this).attr('src', 'img/error.png');
});
//nothing happens if I include this in a called javascript file
有什麼建議?
我仍在學習如何使用它們,但這看起來像是一個組件的工作。 http://emberjs.com/guides/components/ – kaungst 2014-11-24 11:59:05