DateRangePicker – autoUpdateInput:false, autoapply:true not working

Issue

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'
    }
});

Solution

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");
    });

Answered By – Wouter Schoofs

Answer Checked By – David Marino (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.