简体   繁体   中英

Change startDate with datepicker for bootstrap

I have a meeting editing page. the user is allowed to create a new meeting, or they can get a list of meetings and once they select a meeting edit that meeting.

I am using http://eternicode.github.io/bootstrap-datepicker/ for my datepicker

For the create meeting I want start date to be new Date() , and this works fine, however when I go to populate the form with the selected meeting, I can't reset the startDate.

Here is how I set up the datepicker

var datePicker = $("#dp1").datepicker({
        format: "mm/dd/yyyy",
        autoclose: true,
        startDate: new Date(),
    }).on("changeDate", function(e){
        startDate = new Date(e.date);
        // --- more code here --
    });

Then when a user clicks a meeting from the search results, I try to reset the start date but it doesn't work.

My latest try is:

$('#dp1').data('datepicker').setStartDate(new Date(selectedmeeting.startTime));
$('#dp1').datepicker({'setDate': new Date(selectedmeeting.startTime)});

Any ideas should I instantiate the picker differently or is it on the population of the form?

I don't know exactly about your question But maybe it will help you

var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getDate(), nowTemp.getMonth(), 0, 0, 0, 0);
$('#dp1').datepicker({ 
    autoclose: true,
    startDate: now
}).on('changeDate', function(e){
    $('#dpd1').datepicker('setStartDate', e.date);
});

It will change startDate every set a date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM