views:

75

answers:

2

Hello,

I'm using jQuery Datepicker but I'm having trouble when editing records.

// js code
$(function(){
    $(".datepicker").datepicker().datepicker('option', 'dateFormat', 'yy-mm-dd').datepicker('option', 'changeMonth', 'true').datepicker('option', 'changeYear', 'true');
})

// the input
<input type="text" name="valid_from" value="2010-02-27" class="datepicker" />

But when the page is rendered the date shown (and selected when I open the datepicker) is of today.

I'm can't really understand what's going on.

+1  A: 

remove the option:

.datepicker( "option", "gotoCurrent", true );

this moves your date to the current date: gotoCurrent

RJD22
Actually I don't have that piece on the original code, I had putted it there to test and then copied it to the question. So removing it doesn't solve anything.
ferro
+2  A: 

you should also change your code to put all the options in one call like this

  $(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true,changeYear:true});
mcgrailm
Actually this solved my problem. Thanks!
ferro
your welcome, good luck
mcgrailm