jquery datepicker - 覆盖数据属性中的选项
我正在使用这个标记,
<label> Date <input type="text" data-datepicker="{maxDate: '+1d'}" /></label>
<label> Another date <input type="text" data-datepicker="" /></label>
<script>
$('[data-datepicker]').each(function() {
// init the options var with some default values (dateFormat etc)
// that can be overridden by the data-datepicker values
// also, new values can be added to the options from data-datepicker
// such as in the above example "maxDate"
var options = TODO;
$(this).datepicker(options);
});
</script>
我真的不知道从哪里开始使用该选项对象。 从默认值开始似乎是一个好的开始
var options = { dateFormat: 'yy-mm-dd };
但是我如何添加/覆盖数据属性中的值..我只是不知道
I'm using this markup
<label> Date <input type="text" data-datepicker="{maxDate: '+1d'}" /></label>
<label> Another date <input type="text" data-datepicker="" /></label>
<script>
$('[data-datepicker]').each(function() {
// init the options var with some default values (dateFormat etc)
// that can be overridden by the data-datepicker values
// also, new values can be added to the options from data-datepicker
// such as in the above example "maxDate"
var options = TODO;
$(this).datepicker(options);
});
</script>
I don't really know where to start with that options object..
Starting with the default values seems like a good start
var options = { dateFormat: 'yy-mm-dd };
But then how I add/overwrite with values from the data-attribute .. I just don't know
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用此标记(您必须像这样格式化“数据”属性,以便将它们识别为对象):
您可以这样做:
在这里小提琴: http://jsfiddle.net/WrRte/
With this markup (you must format the "data" attribute like this so that they are recognized as objects):
You could do:
fiddle here: http://jsfiddle.net/WrRte/