Pickadate播种从另一个提起

时间:2015-01-27 23:42:29

标签: javascript pickadate

我正在尝试从另一个字段播种一个字段,几乎在那里,但是当我尝试访问' endDate'从onSet中,显然我无法从函数中访问它?:

var endDate = $('.end-date .datepicker').pickadate({
    formatSubmit: 'yyyy-mm-dd'
})

// Would like date from here copied over to endDate on change
var startDate = $('.start-date .datepicker').pickadate({
    formatSubmit: 'yyyy-mm-dd',
    onSet: function(endDate) {
        console.log('Want to set endDate to - ' + this.get('select', 'yyyy/mm/dd'));
        endDate.set('select', this.get('select')); // This line is wrong ..
    }
}) 

1 个答案:

答案 0 :(得分:0)

这有效..

// End date
var endDate = $('.end-date .datepicker').pickadate({
    formatSubmit: 'yyyy-mm-dd'
});
var picker_end_date = endDate.pickadate('picker');

// Start date, onset change enddate
var startDate = $('.start-date .datepicker').pickadate({
    formatSubmit: 'yyyy-mm-dd',
    onSet: function(endDate) {
        //console.log('Want to set endDate to - ' + this.get('select', 'yyyy/mm/dd'));
        picker_end_date.set('select', this.get('select').obj);
    }
})