mdehoog / Semantic-UI-Calendar

Calendar module for Semantic UI
MIT License
805 stars 126 forks source link

initialDate option is not working #63

Closed icodebuster closed 7 years ago

icodebuster commented 7 years ago

From your example, in JSBin the initialDate option should set today's date in the textbox, but it's not working as expected.

$('#example2').calendar({
  type: 'date',
  initialDate: null
});

I want to show today date prefilled in the textbox and also enable user to select dates.

mdehoog commented 7 years ago

initialDate is the date initially selected when the calendar popup first shows. To prefill a date in the textbox, simply set the input's value (see example jsbin).

icodebuster commented 7 years ago

Wouldn't it be nice to have it as an option rather than playing with the text box itself? Everything at one place.

mdehoog commented 7 years ago

You could always use set date if you didn't want to play with the input.

icodebuster commented 7 years ago

Yes, that did it.

This is what I did

$('#date-of-membership').calendar({
                type: 'date',
                today: true,
                maxDate: new Date(),
                formatter: {
                    date: function (date, settings) {
                        if (!date) return '';
                        var day = date.getDate();
                        var month = date.getMonth() + 1;
                        var year = date.getFullYear();
                        return day + '/' + month + '/' + year;
                    }
                },
            }, 'set date', new Date());

Thank you 👍

icodebuster commented 7 years ago

@mdehoog set date is not working in 0.0.8 can you confirm that. The set date was working which I had used previously refer above. Also, how can I check if updateInput = true, fireChange = true is working for set date.

I am working with vue.js and when I change the date it's not getting updated, reason, being change event is not getting triggered.

If possible please update it in JSBin with set date example.

Thank you.

coder8keyboard commented 5 years ago

'set date' works fine on 0.0.8. and the latest Semantic-UI framework. This issue is probably due to initial value is null or date is invalid. If you are using a framework other than Jquery, make sure the values are not null when you creating the calendar object. For e.g. in Aurelia, you need to set @observable for initialDate variable then call 'set date' Also if you are using moment date object, try formatting it. E.g. 'DD-MM-YYYY'