Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Range #14

Open
mohamedKamalEG opened this issue Feb 17, 2020 · 2 comments
Open

Date Range #14

mohamedKamalEG opened this issue Feb 17, 2020 · 2 comments

Comments

@mohamedKamalEG
Copy link

mohamedKamalEG commented Feb 17, 2020

when I set a date to input "fromDate". how to set "minDate" to input "toDate". I tried but "minDate" not applied!
$("#fromDate").on('dp.change', function (data) {
let date = data.date;
$('#toDate').hijriDatePicker({ minDate: date.format("YYYY/M/D") });
});

@balbarak
Copy link
Owner

You have to destroy the picker first. I think we should fix destroy method in next release

for workaround try this

$("#toDate").data().HijriDatePicker.destroy();
$('#toDate').removeData('HijriDatePicker');

// then reinitialize date picker
$('#toDate').hijriDatePicker({ minDate: date.format("YYYY/M/D") });

@diva-smriti
Copy link

diva-smriti commented Jul 23, 2021

it is working just for once , from the next click getting this issue
Cannot read property 'destroy' of undefined

Here is the code

.

$("#DateFrom").on('dp.change', function (event) {
$("#DateTo").data().HijriDatePicker.destroy();
// $('#DateTo').removeData('HijriDatePicker');
$("#DateTo").hijriDatePicker({
locale: "ar-sa",
hijri: true,
format: "dd-mm-yyyy",
hijriFormat: "iDD-iMM-iYYYY",
showSwitcher: false,
maxDate: todayDate,
minDate: event.date.format("YYYY/MM/DD")
});

    });

   
   
    $("#DateTo").on('dp.change', function (event1) {
        $("#DateFrom").data().HijriDatePicker.destroy();
     //   $('#DateFrom').removeData('HijriDatePicker');
        $("#DateFrom").hijriDatePicker({

            locale: "ar-sa",
            hijri: true,
            format: "dd-mm-yyyy",
            hijriFormat: "iDD-iMM-iYYYY",
            showSwitcher: false,
            maxDate: event1.date.format("YYYY/MM/DD")
        });
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants