-->

xeditable defaultViewDate option for datepicker do

2019-09-17 01:30发布

问题:

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/