我有以下(编辑显示currencyId
):
var currencyId = $(".listSelected").attr("rel"); // 110
var currencies = new Currencies();
currencies.fetch({
success:function () {
var currency = currencies.get(currencyId);
user.symbol = currency.get("symbol");
user.country = currency.get("country");
}
});
有时我会遇到以下异常。
Uncaught TypeError: Cannot call method 'get' of undefined on
currency.get("symbol");
我的猜测是我需要将get
语句包装在回调中。我该怎么做?