hehaipeng / mobiscroll

Automatically exported from code.google.com/p/mobiscroll
0 stars 0 forks source link

SetDate will not set date #73

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
<input name="arrival_date" class="datetime scroller" type="datetime-local" 
data-value="2012-02-22T15:33:00Z" value="22/02/2012 03:33 PM" readonly="" 
id="scoller1330286602128">

2. $('.datetime').each(function(){var datetime = new 
Date($(this).attr('data-value'));$(this).scroller({preset: 
'datetime'});$(this).scroller('setDate', datetime)})

Expect scroller to show date object passed to 'setDate'
Instead shows current date and time

What version of the product are you using? On what operating system?
mobiscroll 1.5.3
Google Chrome 17.0.963.56 m

Original issue reported on code.google.com by m...@ourdiggs.co.uk on 26 Feb 2012 at 8:12

GoogleCodeExporter commented 8 years ago
Looks like 'setDate' is not working as excepted. On scroller pop up, Mobiscroll 
tries to parse the input value, and reverts to current date, if value cannot be 
parsed, so the value set with 'setDate' gets lost. There is a third boolean 
parameter for 'setDate', if set to true, it updates the input value as well 
($(this).scroller('setDate', datetime, true))

But in your case all the hustle is completely unnecessary, because Mobiscroll 
parses automatically the date from the input value. Your problem is, that your 
input has a date in dd/mm/yy format, while Mobiscroll defaults to mm/dd/yy. So 
your solution is, to override the default dateformat:

$('.datetime').scroller({preset: 'datetime', dateFormat: 'dd/mm/yy'});

Original comment by diosla...@gmail.com on 27 Feb 2012 at 7:23

GoogleCodeExporter commented 8 years ago
Ah... Thanks for your help!

Original comment by m...@ourdiggs.co.uk on 27 Feb 2012 at 2:11