2017-05-07 63 views
0

這裏我使用的是Material-datetime-picker。但我只需要DOB(出生日期)的日期。因此,在最初的時間出廠日期應該是1990年我應該申請 什麼改變材料的datetime-picker.js如何在Material-Datetime-Picker中設置自己的默認日期

的index.php

var picker = new MaterialDatetimePicker({}) 

    .on('submit', function(d) { 
    var dt = d.format("DD/MM/YYYY"); 
    $("#dob").val(dt); 
    }); 

$('#dob').click(function() { 

picker.open(); 

}); 
+0

向我們展示您爲此編寫的代碼。 – gaganshera

+0

代碼冗長,我怎麼上傳它。 –

+0

只是你調用/初始化日期選擇器的代碼部分 – gaganshera

回答

0

代碼替換材料datetime- picker.js

if (!this.value) { 
    // TODO hack 
    // set/setDate/setTime need refactoring to have single concerns 
    // (set: set the value; setDate/setTime rename to renderDate/renderTime 
    // and deal with updating the view only). 
    // For now this allows us to set the default time using the same quantize 
    // rules as setting the date explicitly. Setting this.value meets setTime|Date's 
    // expectation that we have a value, and `0` guarantees that we will detect 
    this.value = moment(0); 
    this.setDate(this.options.default); 
    this.setTime(this.options.default); 
    } else { 
    this.setDate(this.value); 
    this.setTime(this.value); 
    } 

if (!this.value) { 
    // TODO hack 
    // set/setDate/setTime need refactoring to have single concerns 
    // (set: set the value; setDate/setTime rename to renderDate/renderTime 
    // and deal with updating the view only). 
    // For now this allows us to set the default time using the same quantize 
    // rules as setting the date explicitly. Setting this.value meets setTime|Date's 
    // expectation that we have a value, and `0` guarantees that we will detect 
    this.value = moment(0); 
    this.setDate("12/12/1992"); 
    this.setTime(this.options.default); 
    } else { 
    this.setDate(this.value); 
    this.setTime(this.value); 
    } 
相關問題