获取Framework 7 Calendar的选定日期和当前日期值

时间:2018-02-13 07:06:41

标签: jquery html-framework-7

嗨,我想在框架7日历组件中获取所选日期和当天的值

var calendar = app.calendar.create({
containerEl: '#test-calendar',
monthNames : monthNames,
dayNamesShort: dayNames,
firstDay: 0,
weekHeader: true,
events: [
    {
      id: 1, //example
      title: 'my event',
      from: new Date(year, month, day),
      to: new Date(year, month, 14),
    },
    {
      id: 2, //example
      title: 'my event',
      from: new Date(year, month, day),
      to: new Date(year, month, 14),
    }
],
toolbar: false,
on: {
  init: function(c) {
    $$('.calendar-month-name').text(monthNames[c.currentMonth] +' ' + c.currentYear);
  },
  monthYearChangeStart: function (c) {
    $$('.calendar-month-name').text(monthNames[c.currentMonth] +' ' + c.currentYear);
  },
}

});

例如:

  

var currentday = calendar.getCurrentDay();

     

var selectedday = calendar.getSelectedDay();

     

是否有方法或属性可以在框架7上获得此功能?

1 个答案:

答案 0 :(得分:0)

我找到了答案,但是对于本月的当天,我只是使用选择器来获取它,它仍然是相同的..

on: {
  init: function(calendar) {
    $$('.calendar-month-name').text(monthNames[calendar.currentMonth] +' ' + calendar.currentYear);
  },
  monthYearChangeStart: function (calendar) {
    $$('.calendar-month-name').text(monthNames[calendar.currentMonth] +' ' + calendar.currentYear);
  },
  dayClick: function(calendar, dayEl, year, month, day) {
    var selectedDay = day; // selected day
    var currentDay = $$('.calendar-day-today span').text(); //current day
    console.log(currentDay);
  }
}