0

我正在尝试从另一个 onChange 播种一个字段,几乎就在那里,但是当我尝试从 onSet 中访问“endDate”时抛出错误,显然我无法从函数中访问它?:

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 ..
    }
}) 
4

1 回答 1

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);
    }
})
于 2015-02-02T01:29:24.503 回答