longbill / jquery-date-range-picker

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

Set default range on initialize #386

Closed felipeecst closed 1 month ago

felipeecst commented 6 years ago

I couldn't find in the docs a way to select a default range on datepicker initialize. Here's my configuration:

        jQuery('#id").dateRangePicker({
          language: 'pt'
          startOfWeek: 'monday'
          hoveringTooltip: false
          inline:true,
          container: '#container'
          alwaysOpen:true
          format: 'DD/MM/YYYY'
          separator: ' à '
          showTopbar: false
          autoClose: true
          endDate: moment().toDate()
        }).bind('datepicker-change', (event, obj) => @emitDate(obj) )

Is there a way to set a default start and end date on initialize?

splattne commented 6 years ago

@felipeecst I'm also trying to force the date-picker to open with a specific date (e. g. first month of the year). Did you find a solution to this?

felipeecst commented 6 years ago

Unfortunately not :/

boboci9 commented 5 years ago

Hi, Any news about this? I am also trying to set a default start and end date? Thanks.

creatordigital-paul commented 1 month ago

2024... still can't do this?

monovertex commented 1 month ago

Setting a default value can be achieved by setting a value on the target input. Please see this example: https://jsfiddle.net/monovertex/L1e4qu7p/7/