伙计们,我正在尝试从 DateJS 对象中获取月份名称。如果我 console.log 对象,我会得到它的所有功能。但是,如果我尝试使用,例如 getMonthName/getDayName/isBefore/isAfter/etc,您会收到一条错误消息,指出该函数不存在。
任何想法?
谢谢!
更新:
这是我的代码:
App.Views.DaysTable = Backbone.View.extend({
el: '#dtable',
template: _.template( App.Templates.DaysTable ),
templateTH: _.template( App.Templates.DaysTableTH ),
initialize: function(){
// Defino la fecha corriente
this.fecha = Date.today();
// Defino los eventos de la navegacion
var that = this;
$('#prevWeekBtn').on('click', function(){
that.lessWeek();
});
$('#nextWeekBtn').on('click', function(){
that.plusWeek();
});
$('#todayBtn').on('click', function(){
that.hoy();
});
},
hoy: function(){
this.fecha = Date.today();
this.render();
},
plusWeek: function(){
this.fecha.add(7).days();
this.render();
},
lessWeek: function(){
this.fecha.add(-7).days();
this.render();
},
//between date
render: function(){
var date = this.fecha;
this.$el.html( this.template({ month: this.fecha.getMonthName() }) );
var a = 1;
while(a < 8){
this.$('tr#days').append( this.templateTH({dayName: date.getDayName(), dayDate: date.toString('dd')}) )
date.addDays(1);
a++;
}
this.collection.each( function(bed){
this.fecha.add(-7).days();
bed.set('fecha', this.fecha);
var row = new App.Views.BookingsRow({ model: bed })
this.$('tbody#days').append( row.render().el );
}, this);
this.fecha.add(-7).days();
return this;
// Muestro los dias en cada habitacion
}
});
这是错误消息: TypeError: this.fecha.getMonthName is not a function