Search code examples
javascriptjqueryjquery-mobiledatebox

JQuery Mobile Datebox set using date object


In the API here it says:

Trigger to set specified date

{'method'} === set

{'value'} === value to place in input

{'date'} === the date object being used

I want to set the datebox using my Date object variable "nowTime". But it just does not work. In other posts people usually set the datebox by value (which is a string) which is not quite neat at all. Is there any problem with my code? Or is it the datebox's bug?

My Code:

nowTime = new Date();
nowTime.setHours(8);
nowTime.setMinutes(50);
alert(nowTime.toLocaleString());
    
$("#departureTime").trigger('datebox', {'method':'set', 'date':nowTime}).trigger('datebox', {'method':'doset'});

Solution

  • Works for me if you do the following:

    $("#Date1").datebox('setTheDate', nowTime).trigger('datebox', {'method':'doset'});
    

    DEMO