EasyUI Forum

General Category => General Discussion => Topic started by: featheral on October 24, 2019, 09:03:21 PM



Title: datebox: formatter operates on current date, not selected date
Post by: featheral on October 24, 2019, 09:03:21 PM
Hi.

I'm having a hard time getting formatter to work as-expected.


Code:
<!DOCTYPE html>
<html>
<head>
    <script>
        $(function () {
            $("#foo").datebox({
                formatter: function (date) {
                    let y = date.getFullYear();
                    let m = date.getMonth() + 1;
                    let d = date.getDate();
                    return d + '-' + m + '-' + y;
                }
            })
        })
    </script>
</head>
<body>
    <input id="foo"/>
</body>
</html>

I expected that upon selecting of a date, the datebox will fill the input with the selected date, formatted by the declared formatter. The formatter works, but it renders today's date, instead of the selected one.

Guidance appreciated.


Title: Re: datebox: formatter operates on current date, not selected date
Post by: stworthy on October 26, 2019, 08:25:06 PM
Please refer to this example https://www.jeasyui.com/demo/main/index.php?plugin=DateBox&theme=material-teal&dir=ltr&pitem=Date%20Format&sort=asc