javascript - How to update Jquery Datepicker with a variable? - Stack Overflow

I have a form with Jquery Datepicker and i can save the date in the database.But when i reload the form

I have a form with Jquery Datepicker and i can save the date in the database.

But when i reload the form to update the datas, i would like to have Jquery Datepicker showing the date previoulsy recorded in the database.

I can load it with php. I just need to update the datepicker.

In the documentation, i see :

beforeShowType: Function( Element input, Object inst ) Default: null A function that takes an input field and current datepicker instance and returns an options object >to update the datepicker with. It is called just before the datepicker is displayed.

I think it can be the solution. Could someone give me an example ?

I have a form with Jquery Datepicker and i can save the date in the database.

But when i reload the form to update the datas, i would like to have Jquery Datepicker showing the date previoulsy recorded in the database.

I can load it with php. I just need to update the datepicker.

In the documentation, i see :

beforeShowType: Function( Element input, Object inst ) Default: null A function that takes an input field and current datepicker instance and returns an options object >to update the datepicker with. It is called just before the datepicker is displayed.

I think it can be the solution. Could someone give me an example ?

Share Improve this question asked Oct 11, 2012 at 21:12 Sébastien GicquelSébastien Gicquel 4,3867 gold badges57 silver badges87 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

What did you attach the datepicker to? If you attached it to an input, then you just need to set the value of the input before calling datepicker() on it.

If you haven't initialized the datepicker yet, you can do:

$( '#yourElement' ).datepicker({ defaultDate: yourDate });

Otherwise, you can call the setDate method to set the date on an already initialized datepicker:

$( '#yourElement' ).datepicker( 'setDate', yourDate );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745255001a4618901.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信