2014-06-27 38 views
3

有沒有辦法在刷卡時更改日期選擇器的月份?我的意思是任何方式來顯示下一個和上個月刷卡?Jquery Mobile Datepicker在刷卡上更改月份

這裏是我的方法:

jQuery Mobile的刷卡:

// Bind the swipeHandler callback function to the swipe event on div.box 
$("#main-page").on("swipeleft", swipeLeftHandler).on("swiperight", swipeRightHandler); 

function swipeLeftHandler(event){ 
// $(event.target).addClass("swipe"); 
    console.log('swiped Left'); 
} 

function swipeRightHandler(event){ 
// $(event.target).addClass("swipe"); 
    console.log('swiped Right'); 
} 

,這裏是jQuery Mobile的日期選擇器代碼:

$(".date-input-inline").datepicker({ 
    onChangeMonthYear: function(year, month, inst) { 

     $(".ui-datepicker").fadeOut(0); 

     $(".ui-datepicker").fadeIn("normal"); 

    }, 
    dateFormat: 'yy-mm-dd', 
    yearRange: currentY + ':' + currentY, 
}); 

回答

1

使用getDate方法來獲得日期,加月,然後使用setDate方法設置新日期。

這裏的刷卡權的例子:

var thedate=$(".date-input-inline").datepicker('getDate'); //get date from datepicker 
thedate.setMonth(thedate.getMonth()+1); //add a month 
$(".date-input-inline").datepicker('setDate',thedate); // set the date in datepicker 

向左滑動,將有相同類型的代碼,你只需要一個月的時間中減去。

相關問題