Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery datepicker-覆盖数据属性中的选项_Jquery_Jquery Ui_Jquery Ui Datepicker_Custom Data Attribute - Fatal编程技术网

jquery datepicker-覆盖数据属性中的选项

jquery datepicker-覆盖数据属性中的选项,jquery,jquery-ui,jquery-ui-datepicker,custom-data-attribute,Jquery,Jquery Ui,Jquery Ui Datepicker,Custom Data Attribute,我正在使用这个标记 <label> Date <input type="text" data-datepicker="{maxDate: '+1d'}" /></label> <label> Another date <input type="text" data-datepicker="" /></label> <script> $('[data-datepicker]').each(function() {

我正在使用这个标记

<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>
但是我如何使用数据属性中的值添加/覆盖。。我只是不知道使用这个标记(您必须像这样格式化“data”属性,以便它们被识别为对象):

在这里拉小提琴:

var options = { dateFormat: 'yy-mm-dd }; 
<label> Date <input type="text" data-datepicker='{"maxDate": "+1d"}' /></label>
<label> Another date <input type="text" data-datepicker='{ "dateFormat": "dd-mm-yy"}' /></label>
$('[data-datepicker]').each(function() {
    //standard options
    var options = { dateFormat: "yy-mm-dd"};   
    //additional options
     var additionalOptions = $(this).data("datepicker");
    //merge the additional options into the standard options and override defaults
    jQuery.extend(options, additionalOptions);


      $(this).datepicker(options);
});