DateRangePicker - autoUpdateInput:false, autoapply:true not working

10.9k views Asked by At

I used daterangepicker for my application.

  1. Below code works fine as expected.on load it picks today date and displays. But, i need to show only 'placeholder' value. Not date.
  2. When i use autoUpdateInput : false, it shows 'placeholder' value onload. But, after dates are picked, selected date values are not getting inserted.
  3. Is it possible to do autoUpdateInput: false and autoApply: true make work as expected for my application?

Thanks

JS:

$('input[name="Two way"]').daterangepicker({
    "autoApply": true,
    "minDate": today,
    "locale": {
        format: 'DD MMM YYYY'
    }
});
2

There are 2 answers

0
Wouter Schoofs On BEST ANSWER

You can use function(start,end) {} for this.

Look at this:

        $('#start_date').daterangepicker({
           "showDropdowns": true,
           "autoApply": true,
            locale: {
                format: 'DD/MM/YYYY'
            },autoclose: true,
            "alwaysShowCalendars": true,
            "startDate": '<%= start_date %>',
            "endDate": '<%= end_date %>'
        }, function(start, end) {
              $("#start_date_input").val(start.format('DD/MM/YYYY'));
              $("#end_date_input").val(end.format('DD/MM/YYYY'));
              Materialize.updateTextFields();
        }
    );
    $('#start_date').on("change", function(){
        console.log("changes");
    });
0
Adee On

Answer of 3rd point- Yes it is possible to use autoApply=true & autoUpdateInput=false both at same time.

for this you just need to put autoApply parameter before autoUpdateInput

Look at this:

$('input[name="Two way"]').daterangepicker({
    autoApply: true,
    autoUpdateInput: false,
    minDate: today,
    locale: {
        format: 'DD MMM YYYY'
    }
});