在Calendar Datepicker问题中仅选择月份和年份

时间:2016-07-26 08:26:40

标签: magento datepicker

有没有办法在magento日历中获得类似于this的内容?

这是我的代码:

Calendar.setup({
        inputField: "myfield",
        ifFormat: "%m/%e/%Y",
        showsTime: false,
        button: "_myfield_date_trig",
        align: "Bl",
        singleClick : true,
        disableFunc: function(date) {
                 // show only month and year 
        }
    });

1 个答案:

答案 0 :(得分:0)

您可以尝试this并应用css来隐藏ui日历

<div class="control customer-dob">
<input type="text"
       class="input-text required-entry hasDatepicker"
       id="calendar_inputField"
       name="calendar_inputField"
       aria-required="true" />
<script>
    require([
        "jquery",
        "mage/calendar"
    ], function ($) {
        $("#calendar_inputField").calendar({
            changeYear: true,
            changeMonth: true,
            dateFormat: 'MM/yy',
            yearRange: "2017:2050",
            onClose: function(dateText, inst) {
                $(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
            }
        });
    });
</script>