EasyUI Forum
April 29, 2024, 05:01:26 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datebox: formatter operates on current date, not selected date  (Read 5216 times)
featheral
Newbie
*
Posts: 14


View Profile
« 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!