我正在重寫一些Backbone代碼,並得到一個奇怪的錯誤。這裏是我的代碼:
App.Views.ExploreCard.user = App.Views.ExploreCard.Parent.extend({
name: 'user',
allowUntyped: true,
classes: 'explore-person-box shadowed',
onclick: function() {
window.location.assign(this.data.profilePath);
},
postRender: function() {
App.HCS.redrawHCS(this.$el.find('.score'), this.$el.find('.user-card-avatar-round'));
}
});
和
App.HCS = {
redrawHCS: function(elements) {
elements.each(function(index, value, border) {
var score = $(value).html();
console.log(value);
console.log(border);
if (score <= 33 && score >= 1) {
$(value).css("background-color", "#ff4013");
$(border).css("border", "3px solid #ff4013;");
}
else if (score <= 66 && score >= 34) {
$(value).css("background-color", "rgb(92, 154, 0)");
$(border).css("border", "3px solid rgb(92, 154, 0)");
}
else if (score <= 99 && score >= 67) {
$(value).css("background-color", "#fb9f00");
$(border).css("border", "3px solid #fb9f00;");
}
});
}
};
當我這樣做的價值和邊境console.log
,我總是不確定的邊境。我曾作爲一個全面的檢查切換參數在這條線:
來自:
App.HCS.redrawHCS(this.$el.find('.score'), this.$el.find('.user-card-avatar-round'));
到:
App.HCS.redrawHCS(this.$el.find('.user-card-avatar-round'), this.$el.find('.score'));
不管第二個參數的邊界始終是不確定的順序。
我在Backbone $el
上做了一些Google搜索,但沒有找到任何修復。