私のIDEであるRubyMineは、これは「間違っている可能性がある」と言っています:
function update_top_up_prices_via_localStorage(){
var index = localStorage.getItem("volxs");
$('.product-inner').each(function(){
var product = this.getAttribute('data-product-miles');
var cpm = ((localStorage.getItem("cpm_by_volxs_"+product)).split(","))[index];
$(this).find('table tbody tr td').each(function(){
var top_up_miles = Number(this.getAttribute('data-topup-miles'));
var price = Number(top_up_miles * cpm * 1.06);
price = price.toFixed(2);
$(this).text('\u00A3'+price);
})
});
}
私のIDEはvar top_up_miles
、「の潜在的に無効な使用this
。これにより、JavaScriptthis
が外部コンテキストとクロージャーで同じであることを確認します。
js は Chrome と IE9 で正常に動作します。IE8 では動作しません。
これは間違っていますか?これを書く良い方法はありますか?