无法添加datepicker选项? [英] Can't add datepicker option?

查看:108
本文介绍了无法添加datepicker选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,动态地创建一个新的行与几个表单输入。其中一个输入具有附加的日期戳。我只是在这里帮助下管理这个工作。除了有一个问题留下,一旦我想添加选项到datepicker,它停止工作...



工作小提琴: http://jsfiddle.net/HermesTrismegistus/Bt9eU/



而且不工作的小提琴: http://jsfiddle.net/HermesTrismegistus/TTNEP/



它关于这一行:

  $(。datepick)。 

当我添加选项时..似乎停止运行。

  $(。datepick)。datepicker(option,dateFormat,dd-mm-yy); 

有人知道这个解决方案吗?

解决方案

将两个datepicker实例更改为:

  $(。datepick ).datepicker({dateFormat:dd-mm-yy}); 

您使用的代码在实例化日期戳之后用于更改选项。上述代码在实例化时设置选项。



jsFiddle示例


I have a form wich dynamically creates a new row with a couple of form inputs. One of the inputs has a datepicker attached to it. I just managed with the help from here, to make this work. Except there is one problem left, as soon when i want to add options to the datepicker, it stops working...

Working fiddle: http://jsfiddle.net/HermesTrismegistus/Bt9eU/

And a not working fiddle: http://jsfiddle.net/HermesTrismegistus/TTNEP/

Its about this line:

$(".datepick").datepicker();

When i add the options to it.. It seems to stop functioning.

$(".datepick").datepicker("option", "dateFormat", "dd-mm-yy");

Does someone knows the solution to this?

解决方案

Change both of your datepicker instances to:

$(".datepick").datepicker({ dateFormat: "dd-mm-yy" });

The code you were using works for changing options after you have instantiated a datepicker. The above code sets options when you instantiate it.

jsFiddle example

这篇关于无法添加datepicker选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆