longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 578 forks source link

Custom shortcuts not selecting a range #312

Closed NicolasJEngler closed 7 years ago

NicolasJEngler commented 7 years ago

Custom shortcuts aren't selecting a date range when clicked on. Currently, this is the object with the options that I'm passing to the plugin:

$('#custom-date-1').dateRangePicker({
  format: 'D MMM',
  separator: ' - ',
  autoClose: true,
  singleMonth: true,
  showTopbar: false,
  hoveringTooltip: false,
  showShortcuts: true,
  customShortcuts: [
    {
      name: 'This week',
      dates : function()
        {
          var start = moment().day(0).toDate();
          var end = moment().day(6).toDate();
          return [start,end];
        }
    },
    ...
  ]
});

Am I missing something? I'd appreciate any hint of what is going on.

NicolasJEngler commented 7 years ago

Closing this issue as the main problem was related to the removal of non-breaking spaces, an operation I was doing on the side, generated with the shortcuts.