xeditable defaultViewDate option for datepicker doesn't work

扶醉桌前 提交于 2019-12-12 03:53:37

问题


Any help would be appreciated I tried the below code for x-editable version 1.5.0 the other options like: 'weekStart' works but options like 'setDate', 'defaultViewDate' doesn't work is something wrong with my code? My Code:

<a href="#" id="dob" data-type="date" data-pk="1" data-title="Select date">15/05/1984</a>

<script type="text/javascript>
$('#dob').editable({
  format: 'yyyy-mm-dd',
  viewformat: 'dd/mm/yyyy',
  datepicker: {
    weekStart: 1,
    defaultViewDate: {
      year: 2012,
      month: 11,
      day: 11
    }
  }
});
</script>

回答1:


You can use data-value attribute in your HTML to set default date value

<a href="#" id="dob" data-type="date" data-value="2012-11-11" data-pk="1" data-title="Select date"></a>

this is a workaround check updated jsfiddel.

If you want to open datepicker with default date, when data-value is empty. you can use defaultValue option of editable.

$('#dob').editable({
    format: 'yyyy-mm-dd',
    viewformat: 'dd/mm/yyyy',
    url: '/post',
    defaultValue: "11/11/2012"
})

check example here http://jsfiddle.net/z0yqgL9k/6/



来源:https://stackoverflow.com/questions/40463722/xeditable-defaultviewdate-option-for-datepicker-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!