asmaoui / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

How to get a formatted date string when using custom listener #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I'm using DP with custom listener and I'm setting a text input val in a
form (the simple solution works fine, I just have to use the custom
listener) to the return value - using your example code:

        $(document).ready(function() 
        {

            Date.firstDayOfWeek = 1;
            Date.format = \'yyyy-mm-dd\';

            $(".date-pick")
                .datePicker({createButton:false})
                .bind(
                    "click",
                    function()
                    {
                        $(this).dpDisplay();
                        this.blur();
                        return false;
                    }
                )
                .bind(
                    "dateSelected",
                    function(e, selectedDate, $td)
                    {
                        $(".date-selected").val(selectedDate);
                    }
                );

        }); 

What is the expected output? What do you see instead?
Expect formatted date in format yyyy-mm-dd : 2008-12-15
Getting output: Mon Dec 15 2008 00:00:00 GMT+0200 (South Africa Standard Time)

Please provide a URL to a page displaying the problem.
Testing locally now, but can upload if I REALLY have to.

What version of the datepicker are you using? On what operating system? And
Which Browser?
jQuery 1.2.6
jquery.datePicker.js 5 2008-12-02 23:43:08Z kelvin.luck
WinXP, Apache/1.3.33
FireFox 2.0.0.18 AND IE8

Please provide any additional information below.
I'm a n00b to JS and very new to jQuery, so sorry if this actually has a
very obvious solution... 

Original issue reported on code.google.com by wschip...@gmail.com on 11 Dec 2008 at 2:37

GoogleCodeExporter commented 9 years ago
Try changing this line:

$(".date-selected").val(selectedDate);

To:

$(".date-selected").val(selectedDate.asString());

Let me know if that works,

Kelvin :)

Original comment by kelvin.l...@gmail.com on 12 Dec 2008 at 6:06

GoogleCodeExporter commented 9 years ago
Ah, perfect, thanks.
It's actually quite obvious.

Original comment by wschip...@gmail.com on 14 Dec 2008 at 9:35

GoogleCodeExporter commented 9 years ago
Glad it helped :)

Original comment by kelvin.l...@gmail.com on 14 Dec 2008 at 9:10